Update all models to implement `IHasNamedFiles`

This commit is contained in:
Dean Herbert 2021-11-25 16:35:42 +09:00
parent 416ee2447a
commit 7488ccd5fe
11 changed files with 33 additions and 14 deletions

View File

@ -95,7 +95,7 @@ public bool Equals(BeatmapSetInfo other)
IBeatmapMetadataInfo IBeatmapSetInfo.Metadata => Metadata ?? Beatmaps.FirstOrDefault()?.Metadata ?? new BeatmapMetadata();
IEnumerable<IBeatmapInfo> IBeatmapSetInfo.Beatmaps => Beatmaps;
IEnumerable<INamedFileUsage> IBeatmapSetInfo.Files => Files;
IEnumerable<INamedFileUsage> IHasNamedFiles.Files => Files;
#endregion
}

View File

@ -12,7 +12,7 @@ namespace osu.Game.Beatmaps
/// <summary>
/// A representation of a collection of beatmap difficulties, generally packaged as an ".osz" archive.
/// </summary>
public interface IBeatmapSetInfo : IHasOnlineID<int>, IEquatable<IBeatmapSetInfo>
public interface IBeatmapSetInfo : IHasOnlineID<int>, IEquatable<IBeatmapSetInfo>, IHasNamedFiles
{
/// <summary>
/// The date when this beatmap was imported.
@ -29,11 +29,6 @@ public interface IBeatmapSetInfo : IHasOnlineID<int>, IEquatable<IBeatmapSetInfo
/// </summary>
IEnumerable<IBeatmapInfo> Beatmaps { get; }
/// <summary>
/// All files used by this set.
/// </summary>
IEnumerable<INamedFileUsage> Files { get; }
/// <summary>
/// The maximum star difficulty of all beatmaps in this set.
/// </summary>

View File

@ -0,0 +1,15 @@
// 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;
namespace osu.Game.Database
{
public interface IHasNamedFiles
{
/// <summary>
/// All files used by this model.
/// </summary>
IEnumerable<INamedFileUsage> Files { get; }
}
}

View File

@ -76,7 +76,6 @@ public bool Equals(RealmBeatmapSet? other)
public bool Equals(IBeatmapSetInfo? other) => other is RealmBeatmapSet b && Equals(b);
IEnumerable<IBeatmapInfo> IBeatmapSetInfo.Beatmaps => Beatmaps;
IEnumerable<INamedFileUsage> IBeatmapSetInfo.Files => Files;
IEnumerable<INamedFileUsage> IHasNamedFiles.Files => Files;
}
}

View File

@ -136,7 +136,7 @@ public string AuthorString
IBeatmapMetadataInfo IBeatmapSetInfo.Metadata => metadata;
DateTimeOffset IBeatmapSetInfo.DateAdded => throw new NotImplementedException();
IEnumerable<INamedFileUsage> IBeatmapSetInfo.Files => throw new NotImplementedException();
IEnumerable<INamedFileUsage> IHasNamedFiles.Files => throw new NotImplementedException();
double IBeatmapSetInfo.MaxStarDifficulty => throw new NotImplementedException();
double IBeatmapSetInfo.MaxLength => throw new NotImplementedException();
double IBeatmapSetInfo.MaxBPM => BPM;

View File

@ -8,6 +8,7 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Scoring;
@ -147,6 +148,7 @@ public ScoreInfo CreateScoreInfo(RulesetStore rulesets, BeatmapInfo beatmap = nu
}
public IRulesetInfo Ruleset => new RulesetInfo { OnlineID = RulesetID };
IEnumerable<INamedFileUsage> IHasNamedFiles.Files => throw new NotImplementedException();
IBeatmapInfo IScoreInfo.Beatmap => Beatmap;
}

View File

@ -9,7 +9,7 @@
namespace osu.Game.Scoring
{
public interface IScoreInfo : IHasOnlineID<long>
public interface IScoreInfo : IHasOnlineID<long>, IHasNamedFiles
{
APIUser User { get; }

View File

@ -7,7 +7,7 @@
namespace osu.Game.Scoring
{
public class ScoreFileInfo : INamedFileInfo, IHasPrimaryKey
public class ScoreFileInfo : INamedFileInfo, IHasPrimaryKey, INamedFileUsage
{
public int ID { get; set; }
@ -17,5 +17,7 @@ public class ScoreFileInfo : INamedFileInfo, IHasPrimaryKey
[Required]
public string Filename { get; set; }
IFileInfo INamedFileUsage.File => FileInfo;
}
}

View File

@ -257,5 +257,7 @@ public bool Equals(ScoreInfo other)
bool IScoreInfo.HasReplay => Files.Any();
#endregion
IEnumerable<INamedFileUsage> IHasNamedFiles.Files => Files;
}
}

View File

@ -7,7 +7,7 @@
namespace osu.Game.Skinning
{
public class SkinFileInfo : INamedFileInfo, IHasPrimaryKey
public class SkinFileInfo : INamedFileInfo, IHasPrimaryKey, INamedFileUsage
{
public int ID { get; set; }
@ -19,5 +19,7 @@ public class SkinFileInfo : INamedFileInfo, IHasPrimaryKey
[Required]
public string Filename { get; set; }
IFileInfo INamedFileUsage.File => FileInfo;
}
}

View File

@ -10,7 +10,7 @@
namespace osu.Game.Skinning
{
public class SkinInfo : IHasFiles<SkinFileInfo>, IEquatable<SkinInfo>, IHasPrimaryKey, ISoftDelete
public class SkinInfo : IHasFiles<SkinFileInfo>, IEquatable<SkinInfo>, IHasPrimaryKey, ISoftDelete, IHasNamedFiles
{
internal const int DEFAULT_SKIN = 0;
internal const int CLASSIC_SKIN = -1;
@ -55,5 +55,7 @@ public override string ToString()
string author = Creator == null ? string.Empty : $"({Creator})";
return $"{Name} {author}".Trim();
}
IEnumerable<INamedFileUsage> IHasNamedFiles.Files => Files;
}
}