mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 06:42:56 +08:00
Add support for v9 beatmaps
This commit is contained in:
parent
561b0928bb
commit
02f6e46105
@ -69,8 +69,15 @@ namespace osu.Game.Database
|
|||||||
using (var reader = ArchiveReader.GetReader(storage, path))
|
using (var reader = ArchiveReader.GetReader(storage, path))
|
||||||
metadata = reader.ReadMetadata();
|
metadata = reader.ReadMetadata();
|
||||||
|
|
||||||
if (connection.Table<BeatmapSetInfo>().Count(b => b.BeatmapSetID == metadata.BeatmapSetID) != 0)
|
if (metadata.BeatmapSetID != -1)
|
||||||
return; // TODO: Update this beatmap instead
|
{
|
||||||
|
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
|
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)
|
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
|
//we need metadata
|
||||||
GetChildren(beatmapSetInfo);
|
GetChildren(beatmapSetInfo);
|
||||||
|
|
||||||
if (beatmapSetInfo == null)
|
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)
|
if (beatmapInfo.Metadata == null)
|
||||||
beatmapInfo.Metadata = beatmapSetInfo.Metadata;
|
beatmapInfo.Metadata = beatmapSetInfo.Metadata;
|
||||||
|
@ -13,12 +13,16 @@ namespace osu.Game.Database
|
|||||||
{
|
{
|
||||||
public class BeatmapInfo : IEquatable<BeatmapInfo>
|
public class BeatmapInfo : IEquatable<BeatmapInfo>
|
||||||
{
|
{
|
||||||
[PrimaryKey]
|
[PrimaryKey, AutoIncrement]
|
||||||
|
public int ID { get; set; }
|
||||||
|
|
||||||
public int BeatmapID { get; set; }
|
public int BeatmapID { get; set; }
|
||||||
|
|
||||||
[ForeignKey(typeof(BeatmapSetInfo))]
|
|
||||||
public int BeatmapSetID { get; set; }
|
public int BeatmapSetID { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey(typeof(BeatmapSetInfo))]
|
||||||
|
public int BeatmapSetInfoID { get; set; }
|
||||||
|
|
||||||
[ManyToOne]
|
[ManyToOne]
|
||||||
public BeatmapSetInfo BeatmapSet { get; set; }
|
public BeatmapSetInfo BeatmapSet { get; set; }
|
||||||
|
|
||||||
|
@ -10,20 +10,22 @@ namespace osu.Game.Database
|
|||||||
{
|
{
|
||||||
public class BeatmapSetInfo
|
public class BeatmapSetInfo
|
||||||
{
|
{
|
||||||
[PrimaryKey]
|
[PrimaryKey, AutoIncrement]
|
||||||
public int BeatmapSetID { get; set; }
|
public int ID { get; set; }
|
||||||
|
|
||||||
|
public int BeatmapSetID { get; set; }
|
||||||
|
|
||||||
[OneToOne(CascadeOperations = CascadeOperation.All)]
|
[OneToOne(CascadeOperations = CascadeOperation.All)]
|
||||||
public BeatmapMetadata Metadata { get; set; }
|
public BeatmapMetadata Metadata { get; set; }
|
||||||
|
|
||||||
[NotNull, ForeignKey(typeof(BeatmapMetadata))]
|
[NotNull, ForeignKey(typeof(BeatmapMetadata))]
|
||||||
public int BeatmapMetadataID { get; set; }
|
public int BeatmapMetadataID { get; set; }
|
||||||
|
|
||||||
[OneToMany(CascadeOperations = CascadeOperation.All)]
|
[OneToMany(CascadeOperations = CascadeOperation.All)]
|
||||||
public List<BeatmapInfo> Beatmaps { get; set; }
|
public List<BeatmapInfo> Beatmaps { get; set; }
|
||||||
|
|
||||||
public string Hash { get; set; }
|
public string Hash { get; set; }
|
||||||
|
|
||||||
public string Path { get; set; }
|
public string Path { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -332,7 +332,7 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private void addBeatmapSet(BeatmapSetInfo beatmapSet, BaseGame game)
|
private void addBeatmapSet(BeatmapSetInfo beatmapSet, BaseGame game)
|
||||||
{
|
{
|
||||||
beatmapSet = database.GetWithChildren<BeatmapSetInfo>(beatmapSet.BeatmapSetID);
|
beatmapSet = database.GetWithChildren<BeatmapSetInfo>(beatmapSet.ID);
|
||||||
beatmapSet.Beatmaps.ForEach(b =>
|
beatmapSet.Beatmaps.ForEach(b =>
|
||||||
{
|
{
|
||||||
database.GetChildren(b);
|
database.GetChildren(b);
|
||||||
|
Loading…
Reference in New Issue
Block a user