1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 19:13:20 +08:00

Add support for v9 beatmaps

This commit is contained in:
柯十六夜 2016-12-20 23:56:49 +08:00
parent 561b0928bb
commit 02f6e46105
4 changed files with 31 additions and 18 deletions

View File

@ -69,8 +69,15 @@ namespace osu.Game.Database
using (var reader = ArchiveReader.GetReader(storage, path))
metadata = reader.ReadMetadata();
if (connection.Table<BeatmapSetInfo>().Count(b => b.BeatmapSetID == metadata.BeatmapSetID) != 0)
return; // TODO: Update this beatmap instead
if (metadata.BeatmapSetID != -1)
{
if (connection.Table<BeatmapSetInfo>().Count(b => b.BeatmapSetID == metadata.BeatmapSetID) != 0)
return; // TODO: Update this beatmap instead
}
else
{
// TODO: Another method is required to determine whether two beatmaps with no BeatmapSetID are equal.
}
if (File.Exists(path)) // Not always the case, i.e. for LegacyFilesystemReader
{
@ -144,13 +151,13 @@ namespace osu.Game.Database
public WorkingBeatmap GetWorkingBeatmap(BeatmapInfo beatmapInfo, WorkingBeatmap previous = null)
{
var beatmapSetInfo = Query<BeatmapSetInfo>().FirstOrDefault(s => s.BeatmapSetID == beatmapInfo.BeatmapSetID);
var beatmapSetInfo = Query<BeatmapSetInfo>().FirstOrDefault(s => s.ID == beatmapInfo.BeatmapSetInfoID);
//we need metadata
GetChildren(beatmapSetInfo);
if (beatmapSetInfo == null)
throw new InvalidOperationException($@"Beatmap set {beatmapInfo.BeatmapSetID} is not in the local database.");
throw new InvalidOperationException($@"Beatmap set {beatmapInfo.BeatmapSetInfoID} is not in the local database.");
if (beatmapInfo.Metadata == null)
beatmapInfo.Metadata = beatmapSetInfo.Metadata;

View File

@ -13,12 +13,16 @@ namespace osu.Game.Database
{
public class BeatmapInfo : IEquatable<BeatmapInfo>
{
[PrimaryKey]
[PrimaryKey, AutoIncrement]
public int ID { get; set; }
public int BeatmapID { get; set; }
[ForeignKey(typeof(BeatmapSetInfo))]
public int BeatmapSetID { get; set; }
[ForeignKey(typeof(BeatmapSetInfo))]
public int BeatmapSetInfoID { get; set; }
[ManyToOne]
public BeatmapSetInfo BeatmapSet { get; set; }

View File

@ -10,20 +10,22 @@ namespace osu.Game.Database
{
public class BeatmapSetInfo
{
[PrimaryKey]
public int BeatmapSetID { get; set; }
[PrimaryKey, AutoIncrement]
public int ID { get; set; }
public int BeatmapSetID { get; set; }
[OneToOne(CascadeOperations = CascadeOperation.All)]
public BeatmapMetadata Metadata { get; set; }
[NotNull, ForeignKey(typeof(BeatmapMetadata))]
public BeatmapMetadata Metadata { get; set; }
[NotNull, ForeignKey(typeof(BeatmapMetadata))]
public int BeatmapMetadataID { get; set; }
[OneToMany(CascadeOperations = CascadeOperation.All)]
public List<BeatmapInfo> Beatmaps { get; set; }
public string Hash { get; set; }
[OneToMany(CascadeOperations = CascadeOperation.All)]
public List<BeatmapInfo> Beatmaps { get; set; }
public string Hash { get; set; }
public string Path { get; set; }
}
}

View File

@ -332,7 +332,7 @@ namespace osu.Game.Screens.Select
private void addBeatmapSet(BeatmapSetInfo beatmapSet, BaseGame game)
{
beatmapSet = database.GetWithChildren<BeatmapSetInfo>(beatmapSet.BeatmapSetID);
beatmapSet = database.GetWithChildren<BeatmapSetInfo>(beatmapSet.ID);
beatmapSet.Beatmaps.ForEach(b =>
{
database.GetChildren(b);