Merge branch 'master' into remove-stupid-weak-reference-bindable-events

This commit is contained in:
Dean Herbert
2021-11-08 13:35:49 +09:00
committed by GitHub
249 changed files with 1366 additions and 1186 deletions

View File

@ -17,10 +17,10 @@ using osu.Game.Database;
using osu.Game.IO;
using osu.Game.IO.Archives;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.Notifications;
using osu.Game.Rulesets;
using osu.Game.Skinning;
using osu.Game.Users;
namespace osu.Game.Beatmaps
{
@ -67,7 +67,7 @@ namespace osu.Game.Beatmaps
/// <summary>
/// Create a new <see cref="WorkingBeatmap"/>.
/// </summary>
public WorkingBeatmap CreateNew(RulesetInfo ruleset, User user)
public WorkingBeatmap CreateNew(RulesetInfo ruleset, APIUser user)
{
var metadata = new BeatmapMetadata
{
@ -273,15 +273,11 @@ namespace osu.Game.Beatmaps
remove => beatmapModelDownloader.DownloadFailed -= value;
}
public bool Download(IBeatmapSetInfo model, bool minimiseDownloadSize = false)
{
return beatmapModelDownloader.Download(model, minimiseDownloadSize);
}
public bool Download(IBeatmapSetInfo model, bool minimiseDownloadSize = false) =>
beatmapModelDownloader.Download(model, minimiseDownloadSize);
public ArchiveDownloadRequest<IBeatmapSetInfo> GetExistingDownload(IBeatmapSetInfo model)
{
return beatmapModelDownloader.GetExistingDownload(model);
}
public ArchiveDownloadRequest<IBeatmapSetInfo> GetExistingDownload(IBeatmapSetInfo model) =>
beatmapModelDownloader.GetExistingDownload(model);
#endregion

View File

@ -7,6 +7,7 @@ using System.ComponentModel.DataAnnotations.Schema;
using Newtonsoft.Json;
using osu.Framework.Testing;
using osu.Game.Database;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Users;
#nullable enable
@ -36,41 +37,33 @@ namespace osu.Game.Beatmaps
public List<BeatmapSetInfo> BeatmapSets { get; set; } = new List<BeatmapSetInfo>();
/// <summary>
/// Helper property to deserialize a username to <see cref="User"/>.
/// The author of the beatmaps in this set.
/// </summary>
[JsonIgnore]
public APIUser Author = new APIUser();
/// <summary>
/// Helper property to deserialize a username to <see cref="APIUser"/>.
/// </summary>
[JsonProperty(@"user_id")]
[Column("AuthorID")]
public int AuthorID
{
get => Author?.Id ?? 1;
set
{
Author ??= new User();
Author.Id = value;
}
get => Author.Id; // This should not be used, but is required to make EF work correctly.
set => Author.Id = value;
}
/// <summary>
/// Helper property to deserialize a username to <see cref="User"/>.
/// Helper property to deserialize a username to <see cref="APIUser"/>.
/// </summary>
[JsonProperty(@"creator")]
[Column("Author")]
public string AuthorString
{
get => Author?.Username ?? string.Empty;
set
{
Author ??= new User();
Author.Username = value;
}
get => Author.Username; // This should not be used, but is required to make EF work correctly.
set => Author.Username = value;
}
/// <summary>
/// The author of the beatmaps in this set.
/// </summary>
[JsonIgnore]
public User? Author;
public string Source { get; set; } = string.Empty;
[JsonProperty(@"tags")]
@ -90,6 +83,6 @@ namespace osu.Game.Beatmaps
public override string ToString() => this.GetDisplayTitle();
string IBeatmapMetadataInfo.Author => AuthorString;
IUser IBeatmapMetadataInfo.Author => Author;
}
}

View File

@ -13,7 +13,7 @@ namespace osu.Game.Beatmaps
/// </summary>
public static string[] GetSearchableTerms(this IBeatmapMetadataInfo metadataInfo) => new[]
{
metadataInfo.Author,
metadataInfo.Author.Username,
metadataInfo.Artist,
metadataInfo.ArtistUnicode,
metadataInfo.Title,
@ -27,7 +27,7 @@ namespace osu.Game.Beatmaps
/// </summary>
public static string GetDisplayTitle(this IBeatmapMetadataInfo metadataInfo)
{
string author = string.IsNullOrEmpty(metadataInfo.Author) ? string.Empty : $"({metadataInfo.Author})";
string author = string.IsNullOrEmpty(metadataInfo.Author.Username) ? string.Empty : $"({metadataInfo.Author})";
return $"{metadataInfo.Artist} - {metadataInfo.Title} {author}".Trim();
}
@ -36,7 +36,7 @@ namespace osu.Game.Beatmaps
/// </summary>
public static RomanisableString GetDisplayTitleRomanisable(this IBeatmapMetadataInfo metadataInfo, bool includeCreator = true)
{
string author = !includeCreator || string.IsNullOrEmpty(metadataInfo.Author) ? string.Empty : $"({metadataInfo.Author})";
string author = !includeCreator || string.IsNullOrEmpty(metadataInfo.Author.Username) ? string.Empty : $"({metadataInfo.Author})";
string artistUnicode = string.IsNullOrEmpty(metadataInfo.ArtistUnicode) ? metadataInfo.Artist : metadataInfo.ArtistUnicode;
string titleUnicode = string.IsNullOrEmpty(metadataInfo.TitleUnicode) ? metadataInfo.Title : metadataInfo.TitleUnicode;

View File

@ -129,7 +129,7 @@ namespace osu.Game.Beatmaps.Formats
if (!string.IsNullOrEmpty(beatmap.Metadata.TitleUnicode)) writer.WriteLine(FormattableString.Invariant($"TitleUnicode: {beatmap.Metadata.TitleUnicode}"));
writer.WriteLine(FormattableString.Invariant($"Artist: {beatmap.Metadata.Artist}"));
if (!string.IsNullOrEmpty(beatmap.Metadata.ArtistUnicode)) writer.WriteLine(FormattableString.Invariant($"ArtistUnicode: {beatmap.Metadata.ArtistUnicode}"));
writer.WriteLine(FormattableString.Invariant($"Creator: {beatmap.Metadata.AuthorString}"));
writer.WriteLine(FormattableString.Invariant($"Creator: {beatmap.Metadata.Author.Username}"));
writer.WriteLine(FormattableString.Invariant($"Version: {beatmap.BeatmapInfo.Version}"));
if (!string.IsNullOrEmpty(beatmap.Metadata.Source)) writer.WriteLine(FormattableString.Invariant($"Source: {beatmap.Metadata.Source}"));
if (!string.IsNullOrEmpty(beatmap.Metadata.Tags)) writer.WriteLine(FormattableString.Invariant($"Tags: {beatmap.Metadata.Tags}"));

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using osu.Game.Users;
#nullable enable
@ -35,7 +36,7 @@ namespace osu.Game.Beatmaps
/// <summary>
/// The author of this beatmap.
/// </summary>
string Author { get; } // eventually should be linked to a persisted User.
IUser Author { get; }
/// <summary>
/// The source of this beatmap.