AudioEquals method for BeatmapInfo.

This commit is contained in:
Huo Yaoyuan 2016-11-07 21:52:23 +08:00
parent d1f64cfbfc
commit c59cad2478
3 changed files with 11 additions and 10 deletions

View File

@ -120,7 +120,7 @@ public void Dispose()
public void TransferTo(WorkingBeatmap working)
{
if (track != null && working.BeatmapInfo.Metadata.AudioFile == BeatmapInfo.Metadata.AudioFile && working.BeatmapInfo.BeatmapSet.Path == BeatmapInfo.BeatmapSet.Path)
if (track != null && BeatmapInfo.AudioEquals(working.BeatmapInfo))
working.track = track;
}
}

View File

@ -17,7 +17,7 @@ public class BeatmapInfo : IEquatable<BeatmapInfo>
[ManyToOne]
public BeatmapSetInfo BeatmapSet { get; set; }
[ForeignKey(typeof(BeatmapMetadata))]
public int BeatmapMetadataID { get; set; }
@ -29,9 +29,9 @@ public class BeatmapInfo : IEquatable<BeatmapInfo>
[OneToOne(CascadeOperations = CascadeOperation.All)]
public BaseDifficulty BaseDifficulty { get; set; }
public string Path { get; set; }
// General
public int AudioLeadIn { get; set; }
public bool Countdown { get; set; }
@ -41,7 +41,7 @@ public class BeatmapInfo : IEquatable<BeatmapInfo>
public PlayMode Mode { get; set; }
public bool LetterboxInBreaks { get; set; }
public bool WidescreenStoryboard { get; set; }
// Editor
// This bookmarks stuff is necessary because DB doesn't know how to store int[]
public string StoredBookmarks { get; internal set; }
@ -61,13 +61,15 @@ public int[] Bookmarks
public int BeatDivisor { get; set; }
public int GridSize { get; set; }
public double TimelineZoom { get; set; }
// Metadata
public string Version { get; set; }
public bool Equals(BeatmapInfo other)
{
return BeatmapID == other?.BeatmapID;
}
}
public bool AudioEquals(BeatmapInfo other) => BeatmapSet.Path == other.BeatmapSet.Path && Metadata.AudioFile == other.Metadata.AudioFile;
}
}
}

View File

@ -221,8 +221,7 @@ private void appendToHistory(BeatmapInfo beatmap)
{
if (playHistoryIndex >= 0)
{
BeatmapInfo stackHead = playHistory[playHistoryIndex];
if (beatmap.BeatmapSet.Path == stackHead.BeatmapSet.Path && beatmap.Metadata.AudioFile == stackHead.Metadata.AudioFile)
if (beatmap.AudioEquals(playHistory[playHistoryIndex]))
return;
if (playHistoryIndex < playHistory.Count - 1)
playHistory.RemoveRange(playHistoryIndex + 1, playHistory.Count - playHistoryIndex - 1);