1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 20:07:25 +08:00

Remove all EF models

This commit is contained in:
Dean Herbert 2022-09-15 16:59:03 +09:00
parent 65d1c40dd5
commit 28b15e232d
10 changed files with 0 additions and 977 deletions

View File

@ -1,31 +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.
#nullable disable
using System.ComponentModel.DataAnnotations;
using osu.Game.Database;
using osu.Game.IO;
namespace osu.Game.Beatmaps
{
public class BeatmapSetFileInfo : INamedFileInfo, IHasPrimaryKey, INamedFileUsage
{
public int ID { get; set; }
public bool IsManaged => ID > 0;
public int BeatmapSetInfoID { get; set; }
public EFBeatmapSetInfo BeatmapSetInfo { get; set; }
public int FileInfoID { get; set; }
public FileInfo FileInfo { get; set; }
[Required]
public string Filename { get; set; }
IFileInfo INamedFileUsage.File => FileInfo;
}
}

View File

@ -1,80 +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.
#nullable disable
using System;
using System.ComponentModel.DataAnnotations.Schema;
using osu.Game.Database;
namespace osu.Game.Beatmaps
{
[Table(@"BeatmapDifficulty")]
public class EFBeatmapDifficulty : IHasPrimaryKey, IBeatmapDifficultyInfo
{
/// <summary>
/// The default value used for all difficulty settings except <see cref="SliderMultiplier"/> and <see cref="SliderTickRate"/>.
/// </summary>
public const float DEFAULT_DIFFICULTY = 5;
public int ID { get; set; }
public bool IsManaged => ID > 0;
public float DrainRate { get; set; } = DEFAULT_DIFFICULTY;
public float CircleSize { get; set; } = DEFAULT_DIFFICULTY;
public float OverallDifficulty { get; set; } = DEFAULT_DIFFICULTY;
private float? approachRate;
public EFBeatmapDifficulty()
{
}
public EFBeatmapDifficulty(IBeatmapDifficultyInfo source)
{
CopyFrom(source);
}
public float ApproachRate
{
get => approachRate ?? OverallDifficulty;
set => approachRate = value;
}
public double SliderMultiplier { get; set; } = 1;
public double SliderTickRate { get; set; } = 1;
/// <summary>
/// Returns a shallow-clone of this <see cref="EFBeatmapDifficulty"/>.
/// </summary>
public EFBeatmapDifficulty Clone()
{
var diff = (EFBeatmapDifficulty)Activator.CreateInstance(GetType());
CopyTo(diff);
return diff;
}
public virtual void CopyFrom(IBeatmapDifficultyInfo other)
{
ApproachRate = other.ApproachRate;
DrainRate = other.DrainRate;
CircleSize = other.CircleSize;
OverallDifficulty = other.OverallDifficulty;
SliderMultiplier = other.SliderMultiplier;
SliderTickRate = other.SliderTickRate;
}
public virtual void CopyTo(EFBeatmapDifficulty other)
{
other.ApproachRate = ApproachRate;
other.DrainRate = DrainRate;
other.CircleSize = CircleSize;
other.OverallDifficulty = OverallDifficulty;
other.SliderMultiplier = SliderMultiplier;
other.SliderTickRate = SliderTickRate;
}
}
}

View File

@ -1,183 +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.
#nullable disable
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
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.Rulesets;
using osu.Game.Scoring;
namespace osu.Game.Beatmaps
{
[ExcludeFromDynamicCompile]
[Serializable]
[Table(@"BeatmapInfo")]
public class EFBeatmapInfo : IEquatable<EFBeatmapInfo>, IHasPrimaryKey, IBeatmapInfo
{
public int ID { get; set; }
public bool IsManaged => ID > 0;
public int BeatmapVersion;
private int? onlineID;
[JsonProperty("id")]
[Column("OnlineBeatmapID")]
public int? OnlineID
{
get => onlineID;
set => onlineID = value > 0 ? value : null;
}
[JsonIgnore]
public int BeatmapSetInfoID { get; set; }
public BeatmapOnlineStatus Status { get; set; } = BeatmapOnlineStatus.None;
[Required]
public EFBeatmapSetInfo BeatmapSetInfo { get; set; }
public EFBeatmapMetadata Metadata { get; set; }
[JsonIgnore]
public int BaseDifficultyID { get; set; }
public EFBeatmapDifficulty BaseDifficulty { get; set; }
[NotMapped]
public APIBeatmap OnlineInfo { get; set; }
/// <summary>
/// The playable length in milliseconds of this beatmap.
/// </summary>
public double Length { get; set; }
/// <summary>
/// The most common BPM of this beatmap.
/// </summary>
public double BPM { get; set; }
public string Path { get; set; }
[JsonProperty("file_sha2")]
public string Hash { get; set; }
[JsonIgnore]
public bool Hidden { get; set; }
/// <summary>
/// MD5 is kept for legacy support (matching against replays, osu-web-10 etc.).
/// </summary>
[JsonProperty("file_md5")]
public string MD5Hash { get; set; }
// General
public double AudioLeadIn { get; set; }
public float StackLeniency { get; set; } = 0.7f;
public bool SpecialStyle { get; set; }
[Column("RulesetID")]
public int RulesetInfoID { get; set; }
public EFRulesetInfo RulesetInfo { get; set; }
public bool LetterboxInBreaks { get; set; }
public bool WidescreenStoryboard { get; set; }
public bool EpilepsyWarning { get; set; }
/// <summary>
/// Whether or not sound samples should change rate when playing with speed-changing mods.
/// TODO: only read/write supported for now, requires implementation in gameplay.
/// </summary>
public bool SamplesMatchPlaybackRate { get; set; }
public CountdownType Countdown { get; set; } = CountdownType.Normal;
/// <summary>
/// The number of beats to move the countdown backwards (compared to its default location).
/// </summary>
public int CountdownOffset { get; set; }
[NotMapped]
public int[] Bookmarks { get; set; } = Array.Empty<int>();
public double DistanceSpacing { get; set; }
public int BeatDivisor { get; set; }
public int GridSize { get; set; }
public double TimelineZoom { get; set; }
// Metadata
[Column("Version")]
public string DifficultyName { get; set; }
[JsonProperty("difficulty_rating")]
[Column("StarDifficulty")]
public double StarRating { get; set; }
/// <summary>
/// Currently only populated for beatmap deletion. Use <see cref="ScoreManager"/> to query scores.
/// </summary>
public List<EFScoreInfo> Scores { get; set; }
[JsonIgnore]
public DifficultyRating DifficultyRating => StarDifficulty.GetDifficultyRating(StarRating);
public override string ToString() => this.GetDisplayTitle();
public bool Equals(EFBeatmapInfo other)
{
if (ReferenceEquals(this, other)) return true;
if (other == null) return false;
if (ID != 0 && other.ID != 0)
return ID == other.ID;
return false;
}
public bool Equals(IBeatmapInfo other) => other is EFBeatmapInfo b && Equals(b);
public bool AudioEquals(EFBeatmapInfo other) => other != null && BeatmapSetInfo != null && other.BeatmapSetInfo != null &&
BeatmapSetInfo.Hash == other.BeatmapSetInfo.Hash &&
(Metadata ?? BeatmapSetInfo.Metadata).AudioFile == (other.Metadata ?? other.BeatmapSetInfo.Metadata).AudioFile;
public bool BackgroundEquals(EFBeatmapInfo other) => other != null && BeatmapSetInfo != null && other.BeatmapSetInfo != null &&
BeatmapSetInfo.Hash == other.BeatmapSetInfo.Hash &&
(Metadata ?? BeatmapSetInfo.Metadata).BackgroundFile == (other.Metadata ?? other.BeatmapSetInfo.Metadata).BackgroundFile;
/// <summary>
/// Returns a shallow-clone of this <see cref="EFBeatmapInfo"/>.
/// </summary>
public EFBeatmapInfo Clone() => (EFBeatmapInfo)MemberwiseClone();
#region Implementation of IHasOnlineID
int IHasOnlineID<int>.OnlineID => OnlineID ?? -1;
#endregion
#region Implementation of IBeatmapInfo
[JsonIgnore]
IBeatmapMetadataInfo IBeatmapInfo.Metadata => Metadata ?? BeatmapSetInfo?.Metadata ?? new EFBeatmapMetadata();
[JsonIgnore]
IBeatmapDifficultyInfo IBeatmapInfo.Difficulty => BaseDifficulty;
[JsonIgnore]
IBeatmapSetInfo IBeatmapInfo.BeatmapSet => BeatmapSetInfo;
[JsonIgnore]
IRulesetInfo IBeatmapInfo.Ruleset => RulesetInfo;
#endregion
}
}

View File

@ -1,89 +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 System.Collections.Generic;
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;
namespace osu.Game.Beatmaps
{
[ExcludeFromDynamicCompile]
[Serializable]
[Table(@"BeatmapMetadata")]
public class EFBeatmapMetadata : IEquatable<EFBeatmapMetadata>, IHasPrimaryKey, IBeatmapMetadataInfo
{
public int ID { get; set; }
public bool IsManaged => ID > 0;
public string Title { get; set; } = string.Empty;
[JsonProperty("title_unicode")]
public string TitleUnicode { get; set; } = string.Empty;
public string Artist { get; set; } = string.Empty;
[JsonProperty("artist_unicode")]
public string ArtistUnicode { get; set; } = string.Empty;
[JsonIgnore]
public List<EFBeatmapInfo> Beatmaps { get; set; } = new List<EFBeatmapInfo>();
[JsonIgnore]
public List<EFBeatmapSetInfo> BeatmapSets { get; set; } = new List<EFBeatmapSetInfo>();
/// <summary>
/// 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; // 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="APIUser"/>.
/// </summary>
[JsonProperty(@"creator")]
[Column("Author")]
public string AuthorString
{
get => Author.Username; // This should not be used, but is required to make EF work correctly.
set => Author.Username = value;
}
public string Source { get; set; } = string.Empty;
[JsonProperty(@"tags")]
public string Tags { get; set; } = string.Empty;
/// <summary>
/// The time in milliseconds to begin playing the track for preview purposes.
/// If -1, the track should begin playing at 40% of its length.
/// </summary>
public int PreviewTime { get; set; } = -1;
public string AudioFile { get; set; } = string.Empty;
public string BackgroundFile { get; set; } = string.Empty;
public bool Equals(EFBeatmapMetadata other) => ((IBeatmapMetadataInfo)this).Equals(other);
public override string ToString() => this.GetDisplayTitle();
IUser IBeatmapMetadataInfo.Author => Author;
}
}

View File

@ -1,108 +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.
#nullable disable
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using JetBrains.Annotations;
using Newtonsoft.Json;
using osu.Framework.Testing;
using osu.Game.Database;
using osu.Game.Extensions;
namespace osu.Game.Beatmaps
{
[ExcludeFromDynamicCompile]
[Serializable]
[Table(@"BeatmapSetInfo")]
public class EFBeatmapSetInfo : IHasPrimaryKey, IHasFiles<BeatmapSetFileInfo>, ISoftDelete, IEquatable<EFBeatmapSetInfo>, IBeatmapSetInfo
{
public int ID { get; set; }
public bool IsManaged => ID > 0;
private int? onlineID;
[Column("OnlineBeatmapSetID")]
public int? OnlineID
{
get => onlineID;
set => onlineID = value > 0 ? value : null;
}
public DateTimeOffset DateAdded { get; set; }
public EFBeatmapMetadata Metadata { get; set; }
[NotNull]
public List<EFBeatmapInfo> Beatmaps { get; } = new List<EFBeatmapInfo>();
public BeatmapOnlineStatus Status { get; set; } = BeatmapOnlineStatus.None;
public List<BeatmapSetFileInfo> Files { get; } = new List<BeatmapSetFileInfo>();
/// <summary>
/// The maximum star difficulty of all beatmaps in this set.
/// </summary>
[JsonIgnore]
public double MaxStarDifficulty => Beatmaps.Count == 0 ? 0 : Beatmaps.Max(b => b.StarRating);
/// <summary>
/// The maximum playable length in milliseconds of all beatmaps in this set.
/// </summary>
[JsonIgnore]
public double MaxLength => Beatmaps.Count == 0 ? 0 : Beatmaps.Max(b => b.Length);
/// <summary>
/// The maximum BPM of all beatmaps in this set.
/// </summary>
[JsonIgnore]
public double MaxBPM => Beatmaps.Count == 0 ? 0 : Beatmaps.Max(b => b.BPM);
[NotMapped]
public bool DeletePending { get; set; }
public string Hash { get; set; }
/// <summary>
/// Returns the storage path for the file in this beatmapset with the given filename, if any exists, otherwise null.
/// The path returned is relative to the user file storage.
/// </summary>
/// <param name="filename">The name of the file to get the storage path of.</param>
public string GetPathForFile(string filename) => Files.SingleOrDefault(f => string.Equals(f.Filename, filename, StringComparison.OrdinalIgnoreCase))?.FileInfo.GetStoragePath();
public override string ToString() => Metadata?.ToString() ?? base.ToString();
public bool Protected { get; set; }
public bool Equals(EFBeatmapSetInfo other)
{
if (ReferenceEquals(this, other)) return true;
if (other == null) return false;
if (ID != 0 && other.ID != 0)
return ID == other.ID;
return false;
}
public bool Equals(IBeatmapSetInfo other) => other is EFBeatmapSetInfo b && Equals(b);
#region Implementation of IHasOnlineID
int IHasOnlineID<int>.OnlineID => OnlineID ?? -1;
#endregion
#region Implementation of IBeatmapSetInfo
IBeatmapMetadataInfo IBeatmapSetInfo.Metadata => Metadata ?? Beatmaps.FirstOrDefault()?.Metadata ?? new EFBeatmapMetadata();
IEnumerable<IBeatmapInfo> IBeatmapSetInfo.Beatmaps => Beatmaps;
IEnumerable<INamedFileUsage> IHasNamedFiles.Files => Files;
#endregion
}
}

View File

@ -1,87 +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.
#nullable disable
using System;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics.CodeAnalysis;
using Newtonsoft.Json;
using osu.Framework.Testing;
namespace osu.Game.Rulesets
{
[ExcludeFromDynamicCompile]
[Table(@"RulesetInfo")]
public sealed class EFRulesetInfo : IEquatable<EFRulesetInfo>, IComparable<EFRulesetInfo>, IRulesetInfo
{
public int? ID { get; set; }
public string Name { get; set; }
public string ShortName { get; set; }
public string InstantiationInfo { get; set; }
[JsonIgnore]
public bool Available { get; set; }
// TODO: this should probably be moved to RulesetStore.
public Ruleset CreateInstance()
{
if (!Available)
return null;
var type = Type.GetType(InstantiationInfo);
if (type == null)
return null;
var ruleset = Activator.CreateInstance(type) as Ruleset;
return ruleset;
}
public bool Equals(EFRulesetInfo other) => other != null && ID == other.ID && Available == other.Available && Name == other.Name && InstantiationInfo == other.InstantiationInfo;
public int CompareTo(EFRulesetInfo other) => OnlineID.CompareTo(other.OnlineID);
public int CompareTo(IRulesetInfo other)
{
if (!(other is EFRulesetInfo ruleset))
throw new ArgumentException($@"Object is not of type {nameof(EFRulesetInfo)}.", nameof(other));
return CompareTo(ruleset);
}
public override bool Equals(object obj) => obj is EFRulesetInfo rulesetInfo && Equals(rulesetInfo);
public bool Equals(IRulesetInfo other) => other is RulesetInfo b && Equals(b);
[SuppressMessage("ReSharper", "NonReadonlyMemberInGetHashCode")]
public override int GetHashCode()
{
unchecked
{
int hashCode = ID.HasValue ? ID.GetHashCode() : 0;
hashCode = (hashCode * 397) ^ (InstantiationInfo != null ? InstantiationInfo.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ (Name != null ? Name.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ Available.GetHashCode();
return hashCode;
}
}
public override string ToString() => Name ?? $"{Name} ({ShortName}) ID: {ID}";
#region Implementation of IHasOnlineID
[NotMapped]
public int OnlineID
{
get => ID ?? -1;
set => ID = value >= 0 ? value : null;
}
#endregion
}
}

View File

@ -1,272 +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.
#nullable disable
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using Newtonsoft.Json;
using osu.Framework.Localisation;
using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Users;
using osu.Game.Utils;
namespace osu.Game.Scoring
{
[Table(@"ScoreInfo")]
public class EFScoreInfo : IScoreInfo, IHasFiles<ScoreFileInfo>, IHasPrimaryKey, ISoftDelete, IEquatable<EFScoreInfo>, IDeepCloneable<EFScoreInfo>
{
public int ID { get; set; }
public bool IsManaged => ID > 0;
public ScoreRank Rank { get; set; }
public long TotalScore { get; set; }
[Column(TypeName = "DECIMAL(1,4)")] // TODO: This data type is wrong (should contain more precision). But at the same time, we probably don't need to be storing this in the database.
public double Accuracy { get; set; }
public LocalisableString DisplayAccuracy => Accuracy.FormatAccuracy();
public double? PP { get; set; }
public int MaxCombo { get; set; }
public int Combo { get; set; } // Todo: Shouldn't exist in here
public int RulesetID { get; set; }
[NotMapped]
public bool Passed { get; set; } = true;
public EFRulesetInfo Ruleset { get; set; }
private APIMod[] localAPIMods;
private Mod[] mods;
[NotMapped]
public Mod[] Mods
{
get
{
var rulesetInstance = Ruleset?.CreateInstance();
if (rulesetInstance == null)
return mods ?? Array.Empty<Mod>();
Mod[] scoreMods = Array.Empty<Mod>();
if (mods != null)
scoreMods = mods;
else if (localAPIMods != null)
scoreMods = APIMods.Select(m => m.ToMod(rulesetInstance)).ToArray();
return scoreMods;
}
set
{
localAPIMods = null;
mods = value;
}
}
// Used for API serialisation/deserialisation.
[NotMapped]
public APIMod[] APIMods
{
get
{
if (localAPIMods != null)
return localAPIMods;
if (mods == null)
return Array.Empty<APIMod>();
return localAPIMods = mods.Select(m => new APIMod(m)).ToArray();
}
set
{
localAPIMods = value;
// We potentially can't update this yet due to Ruleset being late-bound, so instead update on read as necessary.
mods = null;
}
}
// Used for database serialisation/deserialisation.
[Column("Mods")]
public string ModsJson
{
get => JsonConvert.SerializeObject(APIMods);
set => APIMods = !string.IsNullOrEmpty(value) ? JsonConvert.DeserializeObject<APIMod[]>(value) : Array.Empty<APIMod>();
}
[NotMapped]
public APIUser User { get; set; }
[Column("User")]
public string UserString
{
get => User?.Username;
set
{
User ??= new APIUser();
User.Username = value;
}
}
[Column("UserID")]
public int? UserID
{
get => User?.Id ?? 1;
set
{
User ??= new APIUser();
User.Id = value ?? 1;
}
}
public int BeatmapInfoID { get; set; }
[Column("Beatmap")]
public EFBeatmapInfo BeatmapInfo { get; set; }
private long? onlineID;
[JsonProperty("id")]
[Column("OnlineScoreID")]
public long? OnlineID
{
get => onlineID;
set => onlineID = value > 0 ? value : null;
}
public DateTimeOffset Date { get; set; }
[NotMapped]
public Dictionary<HitResult, int> Statistics { get; set; } = new Dictionary<HitResult, int>();
[Column("Statistics")]
public string StatisticsJson
{
get => JsonConvert.SerializeObject(Statistics);
set
{
if (value == null)
{
Statistics.Clear();
return;
}
Statistics = JsonConvert.DeserializeObject<Dictionary<HitResult, int>>(value);
}
}
[NotMapped]
public List<HitEvent> HitEvents { get; set; }
public List<ScoreFileInfo> Files { get; } = new List<ScoreFileInfo>();
public string Hash { get; set; }
public bool DeletePending { get; set; }
/// <summary>
/// The position of this score, starting at 1.
/// </summary>
[NotMapped]
public int? Position { get; set; } // TODO: remove after all calls to `CreateScoreInfo` are gone.
/// <summary>
/// Whether this <see cref="EFScoreInfo"/> represents a legacy (osu!stable) score.
/// </summary>
[NotMapped]
public bool IsLegacyScore => Mods.OfType<ModClassic>().Any();
public IEnumerable<HitResultDisplayStatistic> GetStatisticsForDisplay()
{
foreach (var r in Ruleset.CreateInstance().GetHitResults())
{
int value = Statistics.GetValueOrDefault(r.result);
switch (r.result)
{
case HitResult.SmallTickHit:
{
int total = value + Statistics.GetValueOrDefault(HitResult.SmallTickMiss);
if (total > 0)
yield return new HitResultDisplayStatistic(r.result, value, total, r.displayName);
break;
}
case HitResult.LargeTickHit:
{
int total = value + Statistics.GetValueOrDefault(HitResult.LargeTickMiss);
if (total > 0)
yield return new HitResultDisplayStatistic(r.result, value, total, r.displayName);
break;
}
case HitResult.SmallTickMiss:
case HitResult.LargeTickMiss:
break;
default:
yield return new HitResultDisplayStatistic(r.result, value, null, r.displayName);
break;
}
}
}
public EFScoreInfo DeepClone()
{
var clone = (EFScoreInfo)MemberwiseClone();
clone.Statistics = new Dictionary<HitResult, int>(clone.Statistics);
return clone;
}
public override string ToString() => this.GetDisplayTitle();
public bool Equals(EFScoreInfo other)
{
if (ReferenceEquals(this, other)) return true;
if (other == null) return false;
if (ID != 0 && other.ID != 0)
return ID == other.ID;
return false;
}
#region Implementation of IHasOnlineID
long IHasOnlineID<long>.OnlineID => OnlineID ?? -1;
#endregion
#region Implementation of IScoreInfo
IBeatmapInfo IScoreInfo.Beatmap => BeatmapInfo;
IRulesetInfo IScoreInfo.Ruleset => Ruleset;
IUser IScoreInfo.User => User;
bool IScoreInfo.HasReplay => Files.Any();
#endregion
IEnumerable<INamedFileUsage> IHasNamedFiles.Files => Files;
}
}

View File

@ -1,31 +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.
#nullable disable
using System.ComponentModel.DataAnnotations;
using osu.Game.Database;
using osu.Game.IO;
namespace osu.Game.Scoring
{
public class ScoreFileInfo : INamedFileInfo, IHasPrimaryKey, INamedFileUsage
{
public int ID { get; set; }
public bool IsManaged => ID > 0;
public int ScoreInfoID { get; set; }
public EFScoreInfo ScoreInfo { get; set; }
public int FileInfoID { get; set; }
public FileInfo FileInfo { get; set; }
[Required]
public string Filename { get; set; }
IFileInfo INamedFileUsage.File => FileInfo;
}
}

View File

@ -1,65 +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.
#nullable disable
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Game.Database;
using osu.Game.Extensions;
using osu.Game.IO;
namespace osu.Game.Skinning
{
[Table(@"SkinInfo")]
public class EFSkinInfo : IHasFiles<SkinFileInfo>, IEquatable<EFSkinInfo>, IHasPrimaryKey, ISoftDelete
{
internal const int DEFAULT_SKIN = 0;
internal const int CLASSIC_SKIN = -1;
internal const int RANDOM_SKIN = -2;
public int ID { get; set; }
public string Name { get; set; } = string.Empty;
public string Creator { get; set; } = string.Empty;
public string Hash { get; set; }
public string InstantiationInfo { get; set; }
public virtual Skin CreateInstance(IStorageResourceProvider resources)
{
var type = string.IsNullOrEmpty(InstantiationInfo)
// handle the case of skins imported before InstantiationInfo was added.
? typeof(LegacySkin)
: Type.GetType(InstantiationInfo).AsNonNull();
return (Skin)Activator.CreateInstance(type, this, resources);
}
public List<SkinFileInfo> Files { get; set; } = new List<SkinFileInfo>();
public bool DeletePending { get; set; }
public static EFSkinInfo Default { get; } = new EFSkinInfo
{
ID = DEFAULT_SKIN,
Name = "osu! (triangles)",
Creator = "team osu!",
InstantiationInfo = typeof(DefaultSkin).GetInvariantInstantiationInfo()
};
public bool Equals(EFSkinInfo other) => other != null && ID == other.ID;
public override string ToString()
{
string author = Creator == null ? string.Empty : $"({Creator})";
return $"{Name} {author}".Trim();
}
public bool IsManaged => ID > 0;
}
}

View File

@ -1,31 +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.
#nullable disable
using System.ComponentModel.DataAnnotations;
using osu.Game.Database;
using osu.Game.IO;
namespace osu.Game.Skinning
{
public class SkinFileInfo : INamedFileInfo, IHasPrimaryKey, INamedFileUsage
{
public int ID { get; set; }
public bool IsManaged => ID > 0;
public int SkinInfoID { get; set; }
public EFSkinInfo SkinInfo { get; set; }
public int FileInfoID { get; set; }
public FileInfo FileInfo { get; set; }
[Required]
public string Filename { get; set; }
IFileInfo INamedFileUsage.File => FileInfo;
}
}