mirror of
https://github.com/ppy/osu
synced 2025-01-10 16:19:47 +00:00
Add required properties to make realm models backwards compatible
This commit is contained in:
parent
618903c217
commit
c3df58e01c
@ -12,6 +12,11 @@ namespace osu.Game.Beatmaps
|
||||
[MapTo("BeatmapDifficulty")]
|
||||
public class BeatmapDifficulty : EmbeddedObject, 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 float DrainRate { get; set; } = IBeatmapDifficultyInfo.DEFAULT_DIFFICULTY;
|
||||
public float CircleSize { get; set; } = IBeatmapDifficultyInfo.DEFAULT_DIFFICULTY;
|
||||
public float OverallDifficulty { get; set; } = IBeatmapDifficultyInfo.DEFAULT_DIFFICULTY;
|
||||
@ -20,6 +25,15 @@ namespace osu.Game.Beatmaps
|
||||
public double SliderMultiplier { get; set; } = 1;
|
||||
public double SliderTickRate { get; set; } = 1;
|
||||
|
||||
public BeatmapDifficulty()
|
||||
{
|
||||
}
|
||||
|
||||
public BeatmapDifficulty(IBeatmapDifficultyInfo source)
|
||||
{
|
||||
CopyFrom(source);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a shallow-clone of this <see cref="BeatmapDifficulty"/>.
|
||||
/// </summary>
|
||||
@ -30,7 +44,7 @@ namespace osu.Game.Beatmaps
|
||||
return diff;
|
||||
}
|
||||
|
||||
public void CopyTo(BeatmapDifficulty difficulty)
|
||||
public virtual void CopyTo(BeatmapDifficulty difficulty)
|
||||
{
|
||||
difficulty.ApproachRate = ApproachRate;
|
||||
difficulty.DrainRate = DrainRate;
|
||||
@ -40,5 +54,16 @@ namespace osu.Game.Beatmaps
|
||||
difficulty.SliderMultiplier = SliderMultiplier;
|
||||
difficulty.SliderTickRate = SliderTickRate;
|
||||
}
|
||||
|
||||
public virtual void CopyFrom(IBeatmapDifficultyInfo other)
|
||||
{
|
||||
ApproachRate = other.ApproachRate;
|
||||
DrainRate = other.DrainRate;
|
||||
CircleSize = other.CircleSize;
|
||||
OverallDifficulty = other.OverallDifficulty;
|
||||
|
||||
SliderMultiplier = other.SliderMultiplier;
|
||||
SliderTickRate = other.SliderTickRate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ using Newtonsoft.Json;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Models;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Rulesets;
|
||||
using Realms;
|
||||
|
||||
@ -72,7 +73,7 @@ namespace osu.Game.Beatmaps
|
||||
}
|
||||
|
||||
[UsedImplicitly]
|
||||
private BeatmapInfo()
|
||||
public BeatmapInfo()
|
||||
{
|
||||
}
|
||||
|
||||
@ -100,6 +101,13 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
public double TimelineZoom { 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; }
|
||||
|
||||
#endregion
|
||||
|
||||
public bool Equals(BeatmapInfo? other)
|
||||
@ -113,20 +121,53 @@ namespace osu.Game.Beatmaps
|
||||
public bool Equals(IBeatmapInfo? other) => other is BeatmapInfo b && Equals(b);
|
||||
|
||||
public bool AudioEquals(BeatmapInfo? other) => other != null
|
||||
&& BeatmapSet != null
|
||||
&& other.BeatmapSet != null
|
||||
&& BeatmapSet.Hash == other.BeatmapSet.Hash
|
||||
&& Metadata.AudioFile == other.Metadata.AudioFile;
|
||||
&& BeatmapSet != null
|
||||
&& other.BeatmapSet != null
|
||||
&& BeatmapSet.Hash == other.BeatmapSet.Hash
|
||||
&& Metadata.AudioFile == other.Metadata.AudioFile;
|
||||
|
||||
public bool BackgroundEquals(BeatmapInfo? other) => other != null
|
||||
&& BeatmapSet != null
|
||||
&& other.BeatmapSet != null
|
||||
&& BeatmapSet.Hash == other.BeatmapSet.Hash
|
||||
&& Metadata.BackgroundFile == other.Metadata.BackgroundFile;
|
||||
&& BeatmapSet != null
|
||||
&& other.BeatmapSet != null
|
||||
&& BeatmapSet.Hash == other.BeatmapSet.Hash
|
||||
&& Metadata.BackgroundFile == other.Metadata.BackgroundFile;
|
||||
|
||||
IBeatmapMetadataInfo IBeatmapInfo.Metadata => Metadata;
|
||||
IBeatmapSetInfo? IBeatmapInfo.BeatmapSet => BeatmapSet;
|
||||
IRulesetInfo IBeatmapInfo.Ruleset => Ruleset;
|
||||
IBeatmapDifficultyInfo IBeatmapInfo.Difficulty => Difficulty;
|
||||
|
||||
#region Compatibility properties
|
||||
|
||||
[Ignored]
|
||||
public int RulesetID => Ruleset.OnlineID;
|
||||
|
||||
[Ignored]
|
||||
public Guid BeatmapSetInfoID => BeatmapSet?.ID ?? Guid.Empty;
|
||||
|
||||
[Ignored]
|
||||
public BeatmapDifficulty BaseDifficulty
|
||||
{
|
||||
get => Difficulty;
|
||||
set => Difficulty = value;
|
||||
}
|
||||
|
||||
[Ignored]
|
||||
public string? Path => File?.Filename;
|
||||
|
||||
[Ignored]
|
||||
public APIBeatmap? OnlineInfo { get; set; }
|
||||
|
||||
[Ignored]
|
||||
public int? MaxCombo { get; set; }
|
||||
|
||||
[Ignored]
|
||||
public int[] Bookmarks { get; set; } = Array.Empty<int>();
|
||||
|
||||
public int BeatmapVersion;
|
||||
|
||||
public BeatmapInfo Clone() => this.Detach();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -44,5 +44,15 @@ namespace osu.Game.Beatmaps
|
||||
public string BackgroundFile { get; set; } = string.Empty;
|
||||
|
||||
IUser IBeatmapMetadataInfo.Author => Author;
|
||||
|
||||
#region Compatibility properties
|
||||
|
||||
public string AuthorString
|
||||
{
|
||||
get => Author.Username;
|
||||
set => Author.Username = value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -31,5 +31,15 @@ namespace osu.Game.Models
|
||||
}
|
||||
|
||||
IFileInfo INamedFileUsage.File => File;
|
||||
|
||||
#region Compatibility properties
|
||||
|
||||
public RealmFile FileInfo
|
||||
{
|
||||
get => File;
|
||||
set => File = value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ namespace osu.Game.Rulesets
|
||||
}
|
||||
|
||||
[UsedImplicitly]
|
||||
private RulesetInfo()
|
||||
public RulesetInfo()
|
||||
{
|
||||
}
|
||||
|
||||
@ -83,5 +83,11 @@ namespace osu.Game.Rulesets
|
||||
|
||||
return ruleset;
|
||||
}
|
||||
|
||||
#region Compatibility properties
|
||||
|
||||
public int ID => OnlineID;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user