mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 02:42:54 +08:00
Fix many shortcomings and compatibility issues with EF classes post-rename
This commit is contained in:
parent
d7fe3584cd
commit
8d943b5709
@ -15,6 +15,8 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
public int BeatmapSetInfoID { get; set; }
|
public int BeatmapSetInfoID { get; set; }
|
||||||
|
|
||||||
|
public EFBeatmapSetInfo BeatmapSetInfo { get; set; }
|
||||||
|
|
||||||
public int FileInfoID { get; set; }
|
public int FileInfoID { get; set; }
|
||||||
|
|
||||||
public FileInfo FileInfo { get; set; }
|
public FileInfo FileInfo { get; set; }
|
||||||
@ -22,6 +24,6 @@ namespace osu.Game.Beatmaps
|
|||||||
[Required]
|
[Required]
|
||||||
public string Filename { get; set; }
|
public string Filename { get; set; }
|
||||||
|
|
||||||
public IFileInfo File => FileInfo;
|
IFileInfo INamedFileUsage.File => FileInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,12 @@
|
|||||||
// 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;
|
using System;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps
|
namespace osu.Game.Beatmaps
|
||||||
{
|
{
|
||||||
|
[Table(@"BeatmapDifficulty")]
|
||||||
public class EFBeatmapDifficulty : IHasPrimaryKey, IBeatmapDifficultyInfo
|
public class EFBeatmapDifficulty : IHasPrimaryKey, IBeatmapDifficultyInfo
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -16,6 +16,7 @@ namespace osu.Game.Beatmaps
|
|||||||
{
|
{
|
||||||
[ExcludeFromDynamicCompile]
|
[ExcludeFromDynamicCompile]
|
||||||
[Serializable]
|
[Serializable]
|
||||||
|
[Table(@"BeatmapInfo")]
|
||||||
public class EFBeatmapInfo : IEquatable<EFBeatmapInfo>, IHasPrimaryKey, IBeatmapInfo
|
public class EFBeatmapInfo : IEquatable<EFBeatmapInfo>, IHasPrimaryKey, IBeatmapInfo
|
||||||
{
|
{
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
@ -124,7 +125,7 @@ namespace osu.Game.Beatmaps
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Currently only populated for beatmap deletion. Use <see cref="ScoreManager"/> to query scores.
|
/// Currently only populated for beatmap deletion. Use <see cref="ScoreManager"/> to query scores.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<ScoreInfo> Scores { get; set; }
|
public List<EFScoreInfo> Scores { get; set; }
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public DifficultyRating DifficultyRating => BeatmapDifficultyCache.GetDifficultyRating(StarRating);
|
public DifficultyRating DifficultyRating => BeatmapDifficultyCache.GetDifficultyRating(StarRating);
|
||||||
|
@ -16,6 +16,7 @@ namespace osu.Game.Beatmaps
|
|||||||
{
|
{
|
||||||
[ExcludeFromDynamicCompile]
|
[ExcludeFromDynamicCompile]
|
||||||
[Serializable]
|
[Serializable]
|
||||||
|
[Table(@"BeatmapMetadata")]
|
||||||
public class EFBeatmapMetadata : IEquatable<EFBeatmapMetadata>, IHasPrimaryKey, IBeatmapMetadataInfo
|
public class EFBeatmapMetadata : IEquatable<EFBeatmapMetadata>, IHasPrimaryKey, IBeatmapMetadataInfo
|
||||||
{
|
{
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
@ -14,6 +14,8 @@ using osu.Game.Extensions;
|
|||||||
namespace osu.Game.Beatmaps
|
namespace osu.Game.Beatmaps
|
||||||
{
|
{
|
||||||
[ExcludeFromDynamicCompile]
|
[ExcludeFromDynamicCompile]
|
||||||
|
[Serializable]
|
||||||
|
[Table(@"BeatmapSetInfo")]
|
||||||
public class EFBeatmapSetInfo : IHasPrimaryKey, IHasFiles<BeatmapSetFileInfo>, ISoftDelete, IEquatable<EFBeatmapSetInfo>, IBeatmapSetInfo
|
public class EFBeatmapSetInfo : IHasPrimaryKey, IHasFiles<BeatmapSetFileInfo>, ISoftDelete, IEquatable<EFBeatmapSetInfo>, IBeatmapSetInfo
|
||||||
{
|
{
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
|
@ -147,7 +147,7 @@ namespace osu.Game.Database
|
|||||||
|
|
||||||
modelBuilder.Entity<EFBeatmapInfo>().HasOne(b => b.BaseDifficulty);
|
modelBuilder.Entity<EFBeatmapInfo>().HasOne(b => b.BaseDifficulty);
|
||||||
|
|
||||||
modelBuilder.Entity<ScoreInfo>().HasIndex(b => b.OnlineID).IsUnique();
|
modelBuilder.Entity<EFScoreInfo>().HasIndex(b => b.OnlineID).IsUnique();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class OsuDbLoggerFactory : ILoggerFactory
|
private class OsuDbLoggerFactory : ILoggerFactory
|
||||||
|
@ -10,6 +10,7 @@ using osu.Framework.Testing;
|
|||||||
namespace osu.Game.Rulesets
|
namespace osu.Game.Rulesets
|
||||||
{
|
{
|
||||||
[ExcludeFromDynamicCompile]
|
[ExcludeFromDynamicCompile]
|
||||||
|
[Table(@"RulesetInfo")]
|
||||||
public sealed class EFRulesetInfo : IEquatable<EFRulesetInfo>, IRulesetInfo
|
public sealed class EFRulesetInfo : IEquatable<EFRulesetInfo>, IRulesetInfo
|
||||||
{
|
{
|
||||||
public int? ID { get; set; }
|
public int? ID { get; set; }
|
||||||
|
@ -19,6 +19,7 @@ using osu.Game.Utils;
|
|||||||
|
|
||||||
namespace osu.Game.Scoring
|
namespace osu.Game.Scoring
|
||||||
{
|
{
|
||||||
|
[Table(@"ScoreInfo")]
|
||||||
public class EFScoreInfo : IScoreInfo, IHasFiles<ScoreFileInfo>, IHasPrimaryKey, ISoftDelete, IEquatable<EFScoreInfo>, IDeepCloneable<EFScoreInfo>
|
public class EFScoreInfo : IScoreInfo, IHasFiles<ScoreFileInfo>, IHasPrimaryKey, ISoftDelete, IEquatable<EFScoreInfo>, IDeepCloneable<EFScoreInfo>
|
||||||
{
|
{
|
||||||
public int ID { get; set; }
|
public int ID { get; set; }
|
||||||
@ -45,7 +46,7 @@ namespace osu.Game.Scoring
|
|||||||
[NotMapped]
|
[NotMapped]
|
||||||
public bool Passed { get; set; } = true;
|
public bool Passed { get; set; } = true;
|
||||||
|
|
||||||
public RulesetInfo Ruleset { get; set; }
|
public EFRulesetInfo Ruleset { get; set; }
|
||||||
|
|
||||||
private APIMod[] localAPIMods;
|
private APIMod[] localAPIMods;
|
||||||
|
|
||||||
@ -135,9 +136,17 @@ namespace osu.Game.Scoring
|
|||||||
public int BeatmapInfoID { get; set; }
|
public int BeatmapInfoID { get; set; }
|
||||||
|
|
||||||
[Column("Beatmap")]
|
[Column("Beatmap")]
|
||||||
public BeatmapInfo BeatmapInfo { get; set; }
|
public EFBeatmapInfo BeatmapInfo { get; set; }
|
||||||
|
|
||||||
public long? OnlineScoreID { 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; }
|
public DateTimeOffset Date { get; set; }
|
||||||
|
|
||||||
@ -232,24 +241,18 @@ namespace osu.Game.Scoring
|
|||||||
|
|
||||||
public bool Equals(EFScoreInfo other)
|
public bool Equals(EFScoreInfo other)
|
||||||
{
|
{
|
||||||
if (other == null)
|
if (ReferenceEquals(this, other)) return true;
|
||||||
return false;
|
if (other == null) return false;
|
||||||
|
|
||||||
if (ID != 0 && other.ID != 0)
|
if (ID != 0 && other.ID != 0)
|
||||||
return ID == other.ID;
|
return ID == other.ID;
|
||||||
|
|
||||||
if (OnlineScoreID.HasValue && other.OnlineScoreID.HasValue)
|
return false;
|
||||||
return OnlineScoreID == other.OnlineScoreID;
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(Hash) && !string.IsNullOrEmpty(other.Hash))
|
|
||||||
return Hash == other.Hash;
|
|
||||||
|
|
||||||
return ReferenceEquals(this, other);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Implementation of IHasOnlineID
|
#region Implementation of IHasOnlineID
|
||||||
|
|
||||||
public long OnlineID => OnlineScoreID ?? -1;
|
long IHasOnlineID<long>.OnlineID => OnlineID ?? -1;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -13,6 +13,10 @@ namespace osu.Game.Scoring
|
|||||||
|
|
||||||
public bool IsManaged => ID > 0;
|
public bool IsManaged => ID > 0;
|
||||||
|
|
||||||
|
public int ScoreInfoID { get; set; }
|
||||||
|
|
||||||
|
public EFScoreInfo ScoreInfo { get; set; }
|
||||||
|
|
||||||
public int FileInfoID { get; set; }
|
public int FileInfoID { get; set; }
|
||||||
|
|
||||||
public FileInfo FileInfo { get; set; }
|
public FileInfo FileInfo { get; set; }
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
@ -215,14 +214,6 @@ namespace osu.Game.Scoring
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used for database serialisation/deserialisation.
|
|
||||||
[Column("Mods")]
|
|
||||||
public string ModsJson
|
|
||||||
{
|
|
||||||
get => JsonConvert.SerializeObject(APIMods);
|
|
||||||
set => APIMods = JsonConvert.DeserializeObject<APIMod[]>(value) ?? Array.Empty<APIMod>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<HitResultDisplayStatistic> GetStatisticsForDisplay()
|
public IEnumerable<HitResultDisplayStatistic> GetStatisticsForDisplay()
|
||||||
{
|
{
|
||||||
foreach (var r in Ruleset.CreateInstance().GetHitResults())
|
foreach (var r in Ruleset.CreateInstance().GetHitResults())
|
||||||
|
Loading…
Reference in New Issue
Block a user