From 5d5ea5fb2ef803260b1cf05bf426384c49c88471 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 19 Oct 2017 14:05:11 +0900 Subject: [PATCH] Fix all remaining db structure issues --- .../Beatmaps/ManiaBeatmapConverter.cs | 2 +- .../Legacy/DistanceObjectPatternGenerator.cs | 2 +- .../Patterns/Legacy/PatternGenerator.cs | 2 +- .../ManiaDifficultyCalculator.cs | 2 +- .../Scoring/ManiaScoreProcessor.cs | 2 +- .../UI/ManiaRulesetContainer.cs | 10 +- .../Scoring/OsuScoreProcessor.cs | 2 +- .../UI/Cursor/GameplayCursor.cs | 2 +- .../Beatmaps/TaikoBeatmapConverter.cs | 12 +- .../Scoring/TaikoScoreProcessor.cs | 4 +- .../Tests/TestCaseTaikoPlayfield.cs | 2 +- .../UI/TaikoRulesetContainer.cs | 2 +- .../Beatmaps/Formats/OsuLegacyDecoderTest.cs | 2 +- osu.Game/Beatmaps/Beatmap.cs | 2 +- osu.Game/Beatmaps/BeatmapDifficulty.cs | 2 - osu.Game/Beatmaps/BeatmapInfo.cs | 5 +- osu.Game/Beatmaps/BeatmapMetadata.cs | 12 +- osu.Game/Beatmaps/BeatmapStore.cs | 4 +- osu.Game/Beatmaps/DifficultyCalculator.cs | 2 +- osu.Game/Beatmaps/DummyWorkingBeatmap.cs | 2 +- osu.Game/Beatmaps/Formats/BeatmapDecoder.cs | 2 +- osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs | 4 +- osu.Game/Database/OsuDbContext.cs | 10 +- ... 20171019041408_InitialCreate.Designer.cs} | 72 ++--- ...ate.cs => 20171019041408_InitialCreate.cs} | 277 +++++++++--------- .../Migrations/OsuDbContextModelSnapshot.cs | 70 ++--- osu.Game/Rulesets/UI/RulesetContainer.cs | 4 +- osu.Game/Screens/Select/BeatmapDetails.cs | 2 +- .../Screens/Select/Details/AdvancedStats.cs | 10 +- .../Tests/Visual/TestCaseBeatmapDetails.cs | 8 +- .../Tests/Visual/TestCaseBeatmapSetOverlay.cs | 20 +- .../Tests/Visual/TestCasePlaySongSelect.cs | 6 +- .../Visual/TestCaseScrollingPlayfield.cs | 2 +- osu.Game/osu.Game.csproj | 6 +- 34 files changed, 259 insertions(+), 309 deletions(-) rename osu.Game/Migrations/{20171018125509_InitialCreate.Designer.cs => 20171019041408_InitialCreate.Designer.cs} (80%) rename osu.Game/Migrations/{20171018125509_InitialCreate.cs => 20171019041408_InitialCreate.cs} (85%) diff --git a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs index d7c86e1f89..f6d30ad3fa 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/ManiaBeatmapConverter.cs @@ -43,7 +43,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps { beatmap = original; - BeatmapDifficulty difficulty = original.BeatmapInfo.Difficulty; + BeatmapDifficulty difficulty = original.BeatmapInfo.BaseDifficulty; int seed = (int)Math.Round(difficulty.DrainRate + difficulty.CircleSize) * 20 + (int)(difficulty.OverallDifficulty * 41.2) + (int)Math.Round(difficulty.ApproachRate); random = new FastRandom(seed); diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs index 20966a75f7..270c264e0c 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/DistanceObjectPatternGenerator.cs @@ -47,7 +47,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy // The true distance, accounting for any repeats double distance = (distanceData?.Distance ?? 0) * repeatCount; // The velocity of the osu! hit object - calculated as the velocity of a slider - double osuVelocity = osu_base_scoring_distance * beatmap.BeatmapInfo.Difficulty.SliderMultiplier * difficultyPoint.SpeedMultiplier / timingPoint.BeatLength; + double osuVelocity = osu_base_scoring_distance * beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier * difficultyPoint.SpeedMultiplier / timingPoint.BeatLength; // The duration of the osu! hit object double osuDuration = distance / osuVelocity; diff --git a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs index a3173f9784..c38680c3a5 100644 --- a/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs +++ b/osu.Game.Rulesets.Mania/Beatmaps/Patterns/Legacy/PatternGenerator.cs @@ -104,7 +104,7 @@ namespace osu.Game.Rulesets.Mania.Beatmaps.Patterns.Legacy if (drainTime == 0) drainTime = 10000; - BeatmapDifficulty difficulty = Beatmap.BeatmapInfo.Difficulty; + BeatmapDifficulty difficulty = Beatmap.BeatmapInfo.BaseDifficulty; conversionDifficulty = ((difficulty.DrainRate + MathHelper.Clamp(difficulty.ApproachRate, 4, 7)) / 1.5 + Beatmap.HitObjects.Count / drainTime * 9f) / 38f * 5f / 1.15; conversionDifficulty = Math.Min(conversionDifficulty.Value, 12); diff --git a/osu.Game.Rulesets.Mania/ManiaDifficultyCalculator.cs b/osu.Game.Rulesets.Mania/ManiaDifficultyCalculator.cs index b98802db69..784df1f293 100644 --- a/osu.Game.Rulesets.Mania/ManiaDifficultyCalculator.cs +++ b/osu.Game.Rulesets.Mania/ManiaDifficultyCalculator.cs @@ -21,6 +21,6 @@ namespace osu.Game.Rulesets.Mania return 0; } - protected override BeatmapConverter CreateBeatmapConverter() => new ManiaBeatmapConverter(true, (int)Math.Max(1, Math.Round(Beatmap.BeatmapInfo.Difficulty.CircleSize))); + protected override BeatmapConverter CreateBeatmapConverter() => new ManiaBeatmapConverter(true, (int)Math.Max(1, Math.Round(Beatmap.BeatmapInfo.BaseDifficulty.CircleSize))); } } diff --git a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs index a200ba31e2..9b8ebe0070 100644 --- a/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs +++ b/osu.Game.Rulesets.Mania/Scoring/ManiaScoreProcessor.cs @@ -100,7 +100,7 @@ namespace osu.Game.Rulesets.Mania.Scoring protected override void SimulateAutoplay(Beatmap beatmap) { - BeatmapDifficulty difficulty = beatmap.BeatmapInfo.Difficulty; + BeatmapDifficulty difficulty = beatmap.BeatmapInfo.BaseDifficulty; hpMultiplier = BeatmapDifficulty.DifficultyRange(difficulty.DrainRate, hp_multiplier_min, hp_multiplier_mid, hp_multiplier_max); hpMissMultiplier = BeatmapDifficulty.DifficultyRange(difficulty.DrainRate, hp_multiplier_miss_min, hp_multiplier_miss_mid, hp_multiplier_miss_max); diff --git a/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs b/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs index 3b49d81674..08acd46c57 100644 --- a/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs +++ b/osu.Game.Rulesets.Mania/UI/ManiaRulesetContainer.cs @@ -88,18 +88,18 @@ namespace osu.Game.Rulesets.Mania.UI protected override BeatmapConverter CreateBeatmapConverter() { if (IsForCurrentRuleset) - AvailableColumns = (int)Math.Max(1, Math.Round(WorkingBeatmap.BeatmapInfo.Difficulty.CircleSize)); + AvailableColumns = (int)Math.Max(1, Math.Round(WorkingBeatmap.BeatmapInfo.BaseDifficulty.CircleSize)); else { float percentSliderOrSpinner = (float)WorkingBeatmap.Beatmap.HitObjects.Count(h => h is IHasEndTime) / WorkingBeatmap.Beatmap.HitObjects.Count; if (percentSliderOrSpinner < 0.2) AvailableColumns = 7; - else if (percentSliderOrSpinner < 0.3 || Math.Round(WorkingBeatmap.BeatmapInfo.Difficulty.CircleSize) >= 5) - AvailableColumns = Math.Round(WorkingBeatmap.BeatmapInfo.Difficulty.OverallDifficulty) > 5 ? 7 : 6; + else if (percentSliderOrSpinner < 0.3 || Math.Round(WorkingBeatmap.BeatmapInfo.BaseDifficulty.CircleSize) >= 5) + AvailableColumns = Math.Round(WorkingBeatmap.BeatmapInfo.BaseDifficulty.OverallDifficulty) > 5 ? 7 : 6; else if (percentSliderOrSpinner > 0.6) - AvailableColumns = Math.Round(WorkingBeatmap.BeatmapInfo.Difficulty.OverallDifficulty) > 4 ? 5 : 4; + AvailableColumns = Math.Round(WorkingBeatmap.BeatmapInfo.BaseDifficulty.OverallDifficulty) > 4 ? 5 : 4; else - AvailableColumns = Math.Max(4, Math.Min((int)Math.Round(WorkingBeatmap.BeatmapInfo.Difficulty.OverallDifficulty) + 1, 7)); + AvailableColumns = Math.Max(4, Math.Min((int)Math.Round(WorkingBeatmap.BeatmapInfo.BaseDifficulty.OverallDifficulty) + 1, 7)); } return new ManiaBeatmapConverter(IsForCurrentRuleset, AvailableColumns); diff --git a/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs b/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs index 50239bf16c..e4960c5ca2 100644 --- a/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs +++ b/osu.Game.Rulesets.Osu/Scoring/OsuScoreProcessor.cs @@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.Osu.Scoring protected override void SimulateAutoplay(Beatmap beatmap) { - hpDrainRate = beatmap.BeatmapInfo.Difficulty.DrainRate; + hpDrainRate = beatmap.BeatmapInfo.BaseDifficulty.DrainRate; foreach (var obj in beatmap.HitObjects) { diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs b/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs index adfc946f86..d8dd6c7323 100644 --- a/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs +++ b/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs @@ -125,7 +125,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor if (autoCursorScale && beatmap.Value != null) { // if we have a beatmap available, let's get its circle size to figure out an automatic cursor scale modifier. - scale *= (float)(1 - 0.7 * (1 + beatmap.Value.BeatmapInfo.Difficulty.CircleSize - BeatmapDifficulty.DEFAULT_DIFFICULTY) / BeatmapDifficulty.DEFAULT_DIFFICULTY); + scale *= (float)(1 - 0.7 * (1 + beatmap.Value.BeatmapInfo.BaseDifficulty.CircleSize - BeatmapDifficulty.DEFAULT_DIFFICULTY) / BeatmapDifficulty.DEFAULT_DIFFICULTY); } cursorContainer.Scale = new Vector2(scale); diff --git a/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs b/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs index ceaecbb555..9b4a6c47a9 100644 --- a/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs +++ b/osu.Game.Rulesets.Taiko/Beatmaps/TaikoBeatmapConverter.cs @@ -51,7 +51,7 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps { // Rewrite the beatmap info to add the slider velocity multiplier BeatmapInfo info = original.BeatmapInfo.DeepClone(); - info.Difficulty.SliderMultiplier *= legacy_velocity_multiplier; + info.BaseDifficulty.SliderMultiplier *= legacy_velocity_multiplier; Beatmap converted = base.ConvertBeatmap(original); @@ -96,7 +96,7 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps double distance = distanceData.Distance * repeats * legacy_velocity_multiplier; // The velocity of the taiko hit object - calculated as the velocity of a drum roll - double taikoVelocity = taiko_base_distance * beatmap.BeatmapInfo.Difficulty.SliderMultiplier * legacy_velocity_multiplier / speedAdjustedBeatLength; + double taikoVelocity = taiko_base_distance * beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier * legacy_velocity_multiplier / speedAdjustedBeatLength; // The duration of the taiko hit object double taikoDuration = distance / taikoVelocity; @@ -106,12 +106,12 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps speedAdjustedBeatLength *= speedAdjustment; // The velocity of the osu! hit object - calculated as the velocity of a slider - double osuVelocity = osu_base_scoring_distance * beatmap.BeatmapInfo.Difficulty.SliderMultiplier * legacy_velocity_multiplier / speedAdjustedBeatLength; + double osuVelocity = osu_base_scoring_distance * beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier * legacy_velocity_multiplier / speedAdjustedBeatLength; // The duration of the osu! hit object double osuDuration = distance / osuVelocity; // If the drum roll is to be split into hit circles, assume the ticks are 1/8 spaced within the duration of one beat - double tickSpacing = Math.Min(speedAdjustedBeatLength / beatmap.BeatmapInfo.Difficulty.SliderTickRate, taikoDuration / repeats); + double tickSpacing = Math.Min(speedAdjustedBeatLength / beatmap.BeatmapInfo.BaseDifficulty.SliderTickRate, taikoDuration / repeats); if (!isForCurrentRuleset && tickSpacing > 0 && osuDuration < 2 * speedAdjustedBeatLength) { @@ -154,13 +154,13 @@ namespace osu.Game.Rulesets.Taiko.Beatmaps Samples = obj.Samples, IsStrong = strong, Duration = taikoDuration, - TickRate = beatmap.BeatmapInfo.Difficulty.SliderTickRate == 3 ? 3 : 4, + TickRate = beatmap.BeatmapInfo.BaseDifficulty.SliderTickRate == 3 ? 3 : 4, }; } } else if (endTimeData != null) { - double hitMultiplier = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.Difficulty.OverallDifficulty, 3, 5, 7.5) * swell_hit_multiplier; + double hitMultiplier = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.OverallDifficulty, 3, 5, 7.5) * swell_hit_multiplier; yield return new Swell { diff --git a/osu.Game.Rulesets.Taiko/Scoring/TaikoScoreProcessor.cs b/osu.Game.Rulesets.Taiko/Scoring/TaikoScoreProcessor.cs index abdda9676f..752e3bee26 100644 --- a/osu.Game.Rulesets.Taiko/Scoring/TaikoScoreProcessor.cs +++ b/osu.Game.Rulesets.Taiko/Scoring/TaikoScoreProcessor.cs @@ -71,12 +71,12 @@ namespace osu.Game.Rulesets.Taiko.Scoring protected override void SimulateAutoplay(Beatmap beatmap) { - double hpMultiplierNormal = 1 / (hp_hit_great * beatmap.HitObjects.FindAll(o => o is Hit).Count * BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.Difficulty.DrainRate, 0.5, 0.75, 0.98)); + double hpMultiplierNormal = 1 / (hp_hit_great * beatmap.HitObjects.FindAll(o => o is Hit).Count * BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.DrainRate, 0.5, 0.75, 0.98)); hpIncreaseTick = hp_hit_tick; hpIncreaseGreat = hpMultiplierNormal * hp_hit_great; hpIncreaseGood = hpMultiplierNormal * hp_hit_good; - hpIncreaseMiss = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.Difficulty.DrainRate, hp_miss_min, hp_miss_mid, hp_miss_max); + hpIncreaseMiss = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.DrainRate, hp_miss_min, hp_miss_mid, hp_miss_max); foreach (var obj in beatmap.HitObjects) { diff --git a/osu.Game.Rulesets.Taiko/Tests/TestCaseTaikoPlayfield.cs b/osu.Game.Rulesets.Taiko/Tests/TestCaseTaikoPlayfield.cs index 2136d0d86a..14c27bc332 100644 --- a/osu.Game.Rulesets.Taiko/Tests/TestCaseTaikoPlayfield.cs +++ b/osu.Game.Rulesets.Taiko/Tests/TestCaseTaikoPlayfield.cs @@ -67,7 +67,7 @@ namespace osu.Game.Rulesets.Taiko.Tests HitObjects = new List { new CentreHit() }, BeatmapInfo = new BeatmapInfo { - Difficulty = new BeatmapDifficulty(), + BaseDifficulty = new BeatmapDifficulty(), Metadata = new BeatmapMetadata { Artist = @"Unknown", diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoRulesetContainer.cs b/osu.Game.Rulesets.Taiko/UI/TaikoRulesetContainer.cs index f0853aef0e..48ee0a5b42 100644 --- a/osu.Game.Rulesets.Taiko/UI/TaikoRulesetContainer.cs +++ b/osu.Game.Rulesets.Taiko/UI/TaikoRulesetContainer.cs @@ -63,7 +63,7 @@ namespace osu.Game.Rulesets.Taiko.UI StartTime = time, }; - barLine.ApplyDefaults(Beatmap.ControlPointInfo, Beatmap.BeatmapInfo.Difficulty); + barLine.ApplyDefaults(Beatmap.ControlPointInfo, Beatmap.BeatmapInfo.BaseDifficulty); bool isMajor = currentBeat % (int)currentPoint.TimeSignature == 0; Playfield.Add(isMajor ? new DrawableBarLineMajor(barLine) : new DrawableBarLine(barLine)); diff --git a/osu.Game.Tests/Beatmaps/Formats/OsuLegacyDecoderTest.cs b/osu.Game.Tests/Beatmaps/Formats/OsuLegacyDecoderTest.cs index 6bccd47b5c..95b691e07f 100644 --- a/osu.Game.Tests/Beatmaps/Formats/OsuLegacyDecoderTest.cs +++ b/osu.Game.Tests/Beatmaps/Formats/OsuLegacyDecoderTest.cs @@ -85,7 +85,7 @@ namespace osu.Game.Tests.Beatmaps.Formats using (var stream = Resource.OpenResource("Soleily - Renatus (Gamu) [Insane].osu")) { var beatmap = decoder.Decode(new StreamReader(stream)); - var difficulty = beatmap.BeatmapInfo.Difficulty; + var difficulty = beatmap.BeatmapInfo.BaseDifficulty; Assert.AreEqual(6.5f, difficulty.DrainRate); Assert.AreEqual(4, difficulty.CircleSize); Assert.AreEqual(8, difficulty.OverallDifficulty); diff --git a/osu.Game/Beatmaps/Beatmap.cs b/osu.Game/Beatmaps/Beatmap.cs index 56bb48965f..35b6cc2b02 100644 --- a/osu.Game/Beatmaps/Beatmap.cs +++ b/osu.Game/Beatmaps/Beatmap.cs @@ -72,7 +72,7 @@ namespace osu.Game.Beatmaps AuthorString = @"Unknown Creator", }, Version = @"Normal", - Difficulty = new BeatmapDifficulty() + BaseDifficulty = new BeatmapDifficulty() }; } } diff --git a/osu.Game/Beatmaps/BeatmapDifficulty.cs b/osu.Game/Beatmaps/BeatmapDifficulty.cs index e310c4a646..0b0fca8292 100644 --- a/osu.Game/Beatmaps/BeatmapDifficulty.cs +++ b/osu.Game/Beatmaps/BeatmapDifficulty.cs @@ -15,8 +15,6 @@ namespace osu.Game.Beatmaps [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int ID { get; set; } - public int BeatmapInfoID { get; set; } - public float DrainRate { get; set; } = DEFAULT_DIFFICULTY; public float CircleSize { get; set; } = DEFAULT_DIFFICULTY; public float OverallDifficulty { get; set; } = DEFAULT_DIFFICULTY; diff --git a/osu.Game/Beatmaps/BeatmapInfo.cs b/osu.Game/Beatmaps/BeatmapInfo.cs index d2ed5d692c..08cef3f934 100644 --- a/osu.Game/Beatmaps/BeatmapInfo.cs +++ b/osu.Game/Beatmaps/BeatmapInfo.cs @@ -20,7 +20,6 @@ namespace osu.Game.Beatmaps public int BeatmapVersion; [JsonProperty("id")] - [NotMapped] public int? OnlineBeatmapID { get; set; } [JsonProperty("beatmapset_id")] @@ -36,8 +35,7 @@ namespace osu.Game.Beatmaps public int BaseDifficultyID { get; set; } - [Required] - public BeatmapDifficulty Difficulty { get; set; } + public BeatmapDifficulty BaseDifficulty { get; set; } [NotMapped] public BeatmapMetrics Metrics { get; set; } @@ -55,7 +53,6 @@ namespace osu.Game.Beatmaps /// /// MD5 is kept for legacy support (matching against replays, osu-web-10 etc.). /// - [NotMapped] [JsonProperty("file_md5")] public string MD5Hash { get; set; } diff --git a/osu.Game/Beatmaps/BeatmapMetadata.cs b/osu.Game/Beatmaps/BeatmapMetadata.cs index ca8702d222..85bcfecfb8 100644 --- a/osu.Game/Beatmaps/BeatmapMetadata.cs +++ b/osu.Game/Beatmaps/BeatmapMetadata.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Collections.Generic; using System.ComponentModel.DataAnnotations.Schema; using System.Linq; using Newtonsoft.Json; @@ -16,19 +17,14 @@ namespace osu.Game.Beatmaps [NotMapped] public int? OnlineBeatmapSetID { get; set; } - public int? BeatmapSetInfoID { get; set; } - - public BeatmapSetInfo BeatmapSetInfo { get; set; } - - public int? BeatmapInfoID { get; set; } - - public BeatmapInfo BeatmapInfo { get; set; } - public string Title { get; set; } public string TitleUnicode { get; set; } public string Artist { get; set; } public string ArtistUnicode { get; set; } + public List Beatmaps { get; set; } + public List BeatmapSets { get; set; } + /// /// Helper property to deserialize a username to . /// diff --git a/osu.Game/Beatmaps/BeatmapStore.cs b/osu.Game/Beatmaps/BeatmapStore.cs index 21a0b3ef6c..c2ec8c7b05 100644 --- a/osu.Game/Beatmaps/BeatmapStore.cs +++ b/osu.Game/Beatmaps/BeatmapStore.cs @@ -137,7 +137,7 @@ namespace osu.Game.Beatmaps public IEnumerable BeatmapSets => GetContext().BeatmapSetInfo .Include(s => s.Metadata) .Include(s => s.Beatmaps).ThenInclude(s => s.Ruleset) - .Include(s => s.Beatmaps).ThenInclude(b => b.Difficulty) + .Include(s => s.Beatmaps).ThenInclude(b => b.BaseDifficulty) .Include(s => s.Beatmaps).ThenInclude(b => b.Metadata) .Include(s => s.Files).ThenInclude(f => f.FileInfo); @@ -145,6 +145,6 @@ namespace osu.Game.Beatmaps .Include(b => b.BeatmapSet).ThenInclude(s => s.Metadata) .Include(b => b.Metadata) .Include(b => b.Ruleset) - .Include(b => b.Difficulty); + .Include(b => b.BaseDifficulty); } } diff --git a/osu.Game/Beatmaps/DifficultyCalculator.cs b/osu.Game/Beatmaps/DifficultyCalculator.cs index 60cbf0ac61..bb6a292d9d 100644 --- a/osu.Game/Beatmaps/DifficultyCalculator.cs +++ b/osu.Game/Beatmaps/DifficultyCalculator.cs @@ -40,7 +40,7 @@ namespace osu.Game.Beatmaps Objects = CreateBeatmapConverter().Convert(beatmap).HitObjects; foreach (var h in Objects) - h.ApplyDefaults(beatmap.ControlPointInfo, beatmap.BeatmapInfo.Difficulty); + h.ApplyDefaults(beatmap.ControlPointInfo, beatmap.BeatmapInfo.BaseDifficulty); PreprocessHitObjects(); } diff --git a/osu.Game/Beatmaps/DummyWorkingBeatmap.cs b/osu.Game/Beatmaps/DummyWorkingBeatmap.cs index 9a61762fa6..b9376849c1 100644 --- a/osu.Game/Beatmaps/DummyWorkingBeatmap.cs +++ b/osu.Game/Beatmaps/DummyWorkingBeatmap.cs @@ -25,7 +25,7 @@ namespace osu.Game.Beatmaps AuthorString = "no one", }, BeatmapSet = new BeatmapSetInfo(), - Difficulty = new BeatmapDifficulty + BaseDifficulty = new BeatmapDifficulty { DrainRate = 0, CircleSize = 0, diff --git a/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs b/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs index 81695c3b5a..962c6ad49a 100644 --- a/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs +++ b/osu.Game/Beatmaps/Formats/BeatmapDecoder.cs @@ -49,7 +49,7 @@ namespace osu.Game.Beatmaps.Formats BeatmapInfo = new BeatmapInfo { Metadata = new BeatmapMetadata(), - Difficulty = new BeatmapDifficulty(), + BaseDifficulty = new BeatmapDifficulty(), }, }; diff --git a/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs b/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs index 3c06180532..d775ab409b 100644 --- a/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs +++ b/osu.Game/Beatmaps/Formats/OsuLegacyDecoder.cs @@ -196,7 +196,7 @@ namespace osu.Game.Beatmaps.Formats { var pair = splitKeyVal(line, ':'); - var difficulty = beatmap.BeatmapInfo.Difficulty; + var difficulty = beatmap.BeatmapInfo.BaseDifficulty; switch (pair.Key) { case @"HPDrainRate": @@ -674,7 +674,7 @@ namespace osu.Game.Beatmaps.Formats } foreach (var hitObject in beatmap.HitObjects) - hitObject.ApplyDefaults(beatmap.ControlPointInfo, beatmap.BeatmapInfo.Difficulty); + hitObject.ApplyDefaults(beatmap.ControlPointInfo, beatmap.BeatmapInfo.BaseDifficulty); } private KeyValuePair splitKeyVal(string line, char separator) diff --git a/osu.Game/Database/OsuDbContext.cs b/osu.Game/Database/OsuDbContext.cs index cfc5f056ad..37d5bb21c8 100644 --- a/osu.Game/Database/OsuDbContext.cs +++ b/osu.Game/Database/OsuDbContext.cs @@ -65,20 +65,22 @@ namespace osu.Game.Database protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); + modelBuilder.Entity().HasIndex(b => b.MD5Hash); modelBuilder.Entity().HasIndex(b => b.Hash); + modelBuilder.Entity().HasIndex(b => b.DeletePending); modelBuilder.Entity().HasIndex(b => b.Hash); + modelBuilder.Entity().HasIndex(b => b.Variant); modelBuilder.Entity().HasIndex(b => b.IntAction); + modelBuilder.Entity().HasIndex(b => b.Hash).IsUnique(); modelBuilder.Entity().HasIndex(b => b.ReferenceCount); - modelBuilder.Entity().HasIndex(b => b.Name).IsUnique(); - modelBuilder.Entity().HasIndex(b => b.InstantiationInfo).IsUnique(); + modelBuilder.Entity().HasIndex(b => b.Available); - modelBuilder.Entity().HasOne(m => m.BeatmapSetInfo).WithOne(s => s.Metadata).OnDelete(DeleteBehavior.Cascade); - modelBuilder.Entity().HasOne(m => m.BeatmapInfo).WithOne(b => b.Metadata).OnDelete(DeleteBehavior.Cascade); + modelBuilder.Entity().HasOne(b => b.BaseDifficulty); } private class OsuDbLoggerFactory : ILoggerFactory diff --git a/osu.Game/Migrations/20171018125509_InitialCreate.Designer.cs b/osu.Game/Migrations/20171019041408_InitialCreate.Designer.cs similarity index 80% rename from osu.Game/Migrations/20171018125509_InitialCreate.Designer.cs rename to osu.Game/Migrations/20171019041408_InitialCreate.Designer.cs index 28e7e20743..0820041643 100644 --- a/osu.Game/Migrations/20171018125509_InitialCreate.Designer.cs +++ b/osu.Game/Migrations/20171019041408_InitialCreate.Designer.cs @@ -10,7 +10,7 @@ using System; namespace osu.Game.Migrations { [DbContext(typeof(OsuDbContext))] - [Migration("20171018125509_InitialCreate")] + [Migration("20171019041408_InitialCreate")] partial class InitialCreate { protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -26,8 +26,6 @@ namespace osu.Game.Migrations b.Property("ApproachRate"); - b.Property("BeatmapInfoID"); - b.Property("CircleSize"); b.Property("DrainRate"); @@ -40,9 +38,6 @@ namespace osu.Game.Migrations b.HasKey("ID"); - b.HasIndex("BeatmapInfoID") - .IsUnique(); - b.ToTable("BeatmapDifficulty"); }); @@ -73,6 +68,10 @@ namespace osu.Game.Migrations b.Property("MD5Hash"); + b.Property("MetadataID"); + + b.Property("OnlineBeatmapID"); + b.Property("Path"); b.Property("RulesetID"); @@ -93,12 +92,16 @@ namespace osu.Game.Migrations b.HasKey("ID"); + b.HasIndex("BaseDifficultyID"); + b.HasIndex("BeatmapSetInfoID"); b.HasIndex("Hash"); b.HasIndex("MD5Hash"); + b.HasIndex("MetadataID"); + b.HasIndex("RulesetID"); b.ToTable("BeatmapInfo"); @@ -120,10 +123,6 @@ namespace osu.Game.Migrations b.Property("BackgroundFile"); - b.Property("BeatmapInfoID"); - - b.Property("BeatmapSetInfoID"); - b.Property("PreviewTime"); b.Property("Source"); @@ -136,12 +135,6 @@ namespace osu.Game.Migrations b.HasKey("ID"); - b.HasIndex("BeatmapInfoID") - .IsUnique(); - - b.HasIndex("BeatmapSetInfoID") - .IsUnique(); - b.ToTable("BeatmapMetadata"); }); @@ -175,6 +168,8 @@ namespace osu.Game.Migrations b.Property("Hash"); + b.Property("MetadataID"); + b.Property("OnlineBeatmapSetID"); b.Property("Protected"); @@ -185,6 +180,8 @@ namespace osu.Game.Migrations b.HasIndex("Hash"); + b.HasIndex("MetadataID"); + b.ToTable("BeatmapSetInfo"); }); @@ -246,49 +243,31 @@ namespace osu.Game.Migrations b.HasIndex("Available"); - b.HasIndex("InstantiationInfo") - .IsUnique(); - - b.HasIndex("Name") - .IsUnique(); - b.ToTable("RulesetInfo"); }); - modelBuilder.Entity("osu.Game.Beatmaps.BeatmapDifficulty", b => - { - b.HasOne("osu.Game.Beatmaps.BeatmapInfo") - .WithOne("Difficulty") - .HasForeignKey("osu.Game.Beatmaps.BeatmapDifficulty", "BeatmapInfoID") - .OnDelete(DeleteBehavior.Cascade); - }); - modelBuilder.Entity("osu.Game.Beatmaps.BeatmapInfo", b => { + b.HasOne("osu.Game.Beatmaps.BeatmapDifficulty", "BaseDifficulty") + .WithMany() + .HasForeignKey("BaseDifficultyID") + .OnDelete(DeleteBehavior.Cascade); + b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo", "BeatmapSet") .WithMany("Beatmaps") .HasForeignKey("BeatmapSetInfoID") .OnDelete(DeleteBehavior.Cascade); + b.HasOne("osu.Game.Beatmaps.BeatmapMetadata", "Metadata") + .WithMany("Beatmaps") + .HasForeignKey("MetadataID"); + b.HasOne("osu.Game.Rulesets.RulesetInfo", "Ruleset") .WithMany() .HasForeignKey("RulesetID") .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity("osu.Game.Beatmaps.BeatmapMetadata", b => - { - b.HasOne("osu.Game.Beatmaps.BeatmapInfo", "BeatmapInfo") - .WithOne("Metadata") - .HasForeignKey("osu.Game.Beatmaps.BeatmapMetadata", "BeatmapInfoID") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo", "BeatmapSetInfo") - .WithOne("Metadata") - .HasForeignKey("osu.Game.Beatmaps.BeatmapMetadata", "BeatmapSetInfoID") - .OnDelete(DeleteBehavior.Cascade); - }); - modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetFileInfo", b => { b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo") @@ -301,6 +280,13 @@ namespace osu.Game.Migrations .HasForeignKey("FileInfoID") .OnDelete(DeleteBehavior.Cascade); }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetInfo", b => + { + b.HasOne("osu.Game.Beatmaps.BeatmapMetadata", "Metadata") + .WithMany("BeatmapSets") + .HasForeignKey("MetadataID"); + }); #pragma warning restore 612, 618 } } diff --git a/osu.Game/Migrations/20171018125509_InitialCreate.cs b/osu.Game/Migrations/20171019041408_InitialCreate.cs similarity index 85% rename from osu.Game/Migrations/20171018125509_InitialCreate.cs rename to osu.Game/Migrations/20171019041408_InitialCreate.cs index 512ffa2790..23e5b6f8bb 100644 --- a/osu.Game/Migrations/20171018125509_InitialCreate.cs +++ b/osu.Game/Migrations/20171019041408_InitialCreate.cs @@ -9,19 +9,43 @@ namespace osu.Game.Migrations protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( - name: "BeatmapSetInfo", + name: "BeatmapDifficulty", columns: table => new { ID = table.Column(type: "INTEGER", nullable: false) .Annotation("Sqlite:Autoincrement", true), - DeletePending = table.Column(type: "INTEGER", nullable: false), - Hash = table.Column(type: "TEXT", nullable: true), - OnlineBeatmapSetID = table.Column(type: "INTEGER", nullable: true), - Protected = table.Column(type: "INTEGER", nullable: false) + ApproachRate = table.Column(type: "REAL", nullable: false), + CircleSize = table.Column(type: "REAL", nullable: false), + DrainRate = table.Column(type: "REAL", nullable: false), + OverallDifficulty = table.Column(type: "REAL", nullable: false), + SliderMultiplier = table.Column(type: "REAL", nullable: false), + SliderTickRate = table.Column(type: "REAL", nullable: false) }, constraints: table => { - table.PrimaryKey("PK_BeatmapSetInfo", x => x.ID); + table.PrimaryKey("PK_BeatmapDifficulty", x => x.ID); + }); + + migrationBuilder.CreateTable( + name: "BeatmapMetadata", + columns: table => new + { + ID = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Artist = table.Column(type: "TEXT", nullable: true), + ArtistUnicode = table.Column(type: "TEXT", nullable: true), + AudioFile = table.Column(type: "TEXT", nullable: true), + Author = table.Column(type: "TEXT", nullable: true), + BackgroundFile = table.Column(type: "TEXT", nullable: true), + PreviewTime = table.Column(type: "INTEGER", nullable: false), + Source = table.Column(type: "TEXT", nullable: true), + Tags = table.Column(type: "TEXT", nullable: true), + Title = table.Column(type: "TEXT", nullable: true), + TitleUnicode = table.Column(type: "TEXT", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_BeatmapMetadata", x => x.ID); }); migrationBuilder.CreateTable( @@ -69,6 +93,87 @@ namespace osu.Game.Migrations table.PrimaryKey("PK_RulesetInfo", x => x.ID); }); + migrationBuilder.CreateTable( + name: "BeatmapSetInfo", + columns: table => new + { + ID = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + DeletePending = table.Column(type: "INTEGER", nullable: false), + Hash = table.Column(type: "TEXT", nullable: true), + MetadataID = table.Column(type: "INTEGER", nullable: true), + OnlineBeatmapSetID = table.Column(type: "INTEGER", nullable: true), + Protected = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_BeatmapSetInfo", x => x.ID); + table.ForeignKey( + name: "FK_BeatmapSetInfo_BeatmapMetadata_MetadataID", + column: x => x.MetadataID, + principalTable: "BeatmapMetadata", + principalColumn: "ID", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "BeatmapInfo", + columns: table => new + { + ID = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + AudioLeadIn = table.Column(type: "INTEGER", nullable: false), + BaseDifficultyID = table.Column(type: "INTEGER", nullable: false), + BeatDivisor = table.Column(type: "INTEGER", nullable: false), + BeatmapSetInfoID = table.Column(type: "INTEGER", nullable: false), + Countdown = table.Column(type: "INTEGER", nullable: false), + DistanceSpacing = table.Column(type: "REAL", nullable: false), + GridSize = table.Column(type: "INTEGER", nullable: false), + Hash = table.Column(type: "TEXT", nullable: true), + Hidden = table.Column(type: "INTEGER", nullable: false), + LetterboxInBreaks = table.Column(type: "INTEGER", nullable: false), + MD5Hash = table.Column(type: "TEXT", nullable: true), + MetadataID = table.Column(type: "INTEGER", nullable: true), + OnlineBeatmapID = table.Column(type: "INTEGER", nullable: true), + Path = table.Column(type: "TEXT", nullable: true), + RulesetID = table.Column(type: "INTEGER", nullable: false), + SpecialStyle = table.Column(type: "INTEGER", nullable: false), + StackLeniency = table.Column(type: "REAL", nullable: false), + StarDifficulty = table.Column(type: "REAL", nullable: false), + StoredBookmarks = table.Column(type: "TEXT", nullable: true), + TimelineZoom = table.Column(type: "REAL", nullable: false), + Version = table.Column(type: "TEXT", nullable: true), + WidescreenStoryboard = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_BeatmapInfo", x => x.ID); + table.ForeignKey( + name: "FK_BeatmapInfo_BeatmapDifficulty_BaseDifficultyID", + column: x => x.BaseDifficultyID, + principalTable: "BeatmapDifficulty", + principalColumn: "ID", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_BeatmapInfo_BeatmapSetInfo_BeatmapSetInfoID", + column: x => x.BeatmapSetInfoID, + principalTable: "BeatmapSetInfo", + principalColumn: "ID", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_BeatmapInfo_BeatmapMetadata_MetadataID", + column: x => x.MetadataID, + principalTable: "BeatmapMetadata", + principalColumn: "ID", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_BeatmapInfo_RulesetInfo_RulesetID", + column: x => x.RulesetID, + principalTable: "RulesetInfo", + principalColumn: "ID", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "BeatmapSetFileInfo", columns: table => new @@ -96,116 +201,10 @@ namespace osu.Game.Migrations onDelete: ReferentialAction.Cascade); }); - migrationBuilder.CreateTable( - name: "BeatmapInfo", - columns: table => new - { - ID = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - AudioLeadIn = table.Column(type: "INTEGER", nullable: false), - BaseDifficultyID = table.Column(type: "INTEGER", nullable: false), - BeatDivisor = table.Column(type: "INTEGER", nullable: false), - BeatmapSetInfoID = table.Column(type: "INTEGER", nullable: false), - Countdown = table.Column(type: "INTEGER", nullable: false), - DistanceSpacing = table.Column(type: "REAL", nullable: false), - GridSize = table.Column(type: "INTEGER", nullable: false), - Hash = table.Column(type: "TEXT", nullable: true), - Hidden = table.Column(type: "INTEGER", nullable: false), - LetterboxInBreaks = table.Column(type: "INTEGER", nullable: false), - MD5Hash = table.Column(type: "TEXT", nullable: true), - Path = table.Column(type: "TEXT", nullable: true), - RulesetID = table.Column(type: "INTEGER", nullable: false), - SpecialStyle = table.Column(type: "INTEGER", nullable: false), - StackLeniency = table.Column(type: "REAL", nullable: false), - StarDifficulty = table.Column(type: "REAL", nullable: false), - StoredBookmarks = table.Column(type: "TEXT", nullable: true), - TimelineZoom = table.Column(type: "REAL", nullable: false), - Version = table.Column(type: "TEXT", nullable: true), - WidescreenStoryboard = table.Column(type: "INTEGER", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_BeatmapInfo", x => x.ID); - table.ForeignKey( - name: "FK_BeatmapInfo_BeatmapSetInfo_BeatmapSetInfoID", - column: x => x.BeatmapSetInfoID, - principalTable: "BeatmapSetInfo", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_BeatmapInfo_RulesetInfo_RulesetID", - column: x => x.RulesetID, - principalTable: "RulesetInfo", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "BeatmapDifficulty", - columns: table => new - { - ID = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - ApproachRate = table.Column(type: "REAL", nullable: false), - BeatmapInfoID = table.Column(type: "INTEGER", nullable: false), - CircleSize = table.Column(type: "REAL", nullable: false), - DrainRate = table.Column(type: "REAL", nullable: false), - OverallDifficulty = table.Column(type: "REAL", nullable: false), - SliderMultiplier = table.Column(type: "REAL", nullable: false), - SliderTickRate = table.Column(type: "REAL", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_BeatmapDifficulty", x => x.ID); - table.ForeignKey( - name: "FK_BeatmapDifficulty_BeatmapInfo_BeatmapInfoID", - column: x => x.BeatmapInfoID, - principalTable: "BeatmapInfo", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "BeatmapMetadata", - columns: table => new - { - ID = table.Column(type: "INTEGER", nullable: false) - .Annotation("Sqlite:Autoincrement", true), - Artist = table.Column(type: "TEXT", nullable: true), - ArtistUnicode = table.Column(type: "TEXT", nullable: true), - AudioFile = table.Column(type: "TEXT", nullable: true), - Author = table.Column(type: "TEXT", nullable: true), - BackgroundFile = table.Column(type: "TEXT", nullable: true), - BeatmapInfoID = table.Column(type: "INTEGER", nullable: true), - BeatmapSetInfoID = table.Column(type: "INTEGER", nullable: true), - PreviewTime = table.Column(type: "INTEGER", nullable: false), - Source = table.Column(type: "TEXT", nullable: true), - Tags = table.Column(type: "TEXT", nullable: true), - Title = table.Column(type: "TEXT", nullable: true), - TitleUnicode = table.Column(type: "TEXT", nullable: true) - }, - constraints: table => - { - table.PrimaryKey("PK_BeatmapMetadata", x => x.ID); - table.ForeignKey( - name: "FK_BeatmapMetadata_BeatmapInfo_BeatmapInfoID", - column: x => x.BeatmapInfoID, - principalTable: "BeatmapInfo", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_BeatmapMetadata_BeatmapSetInfo_BeatmapSetInfoID", - column: x => x.BeatmapSetInfoID, - principalTable: "BeatmapSetInfo", - principalColumn: "ID", - onDelete: ReferentialAction.Cascade); - }); - migrationBuilder.CreateIndex( - name: "IX_BeatmapDifficulty_BeatmapInfoID", - table: "BeatmapDifficulty", - column: "BeatmapInfoID", - unique: true); + name: "IX_BeatmapInfo_BaseDifficultyID", + table: "BeatmapInfo", + column: "BaseDifficultyID"); migrationBuilder.CreateIndex( name: "IX_BeatmapInfo_BeatmapSetInfoID", @@ -222,23 +221,16 @@ namespace osu.Game.Migrations table: "BeatmapInfo", column: "MD5Hash"); + migrationBuilder.CreateIndex( + name: "IX_BeatmapInfo_MetadataID", + table: "BeatmapInfo", + column: "MetadataID"); + migrationBuilder.CreateIndex( name: "IX_BeatmapInfo_RulesetID", table: "BeatmapInfo", column: "RulesetID"); - migrationBuilder.CreateIndex( - name: "IX_BeatmapMetadata_BeatmapInfoID", - table: "BeatmapMetadata", - column: "BeatmapInfoID", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_BeatmapMetadata_BeatmapSetInfoID", - table: "BeatmapMetadata", - column: "BeatmapSetInfoID", - unique: true); - migrationBuilder.CreateIndex( name: "IX_BeatmapSetFileInfo_BeatmapSetInfoID", table: "BeatmapSetFileInfo", @@ -259,6 +251,11 @@ namespace osu.Game.Migrations table: "BeatmapSetInfo", column: "Hash"); + migrationBuilder.CreateIndex( + name: "IX_BeatmapSetInfo_MetadataID", + table: "BeatmapSetInfo", + column: "MetadataID"); + migrationBuilder.CreateIndex( name: "IX_FileInfo_Hash", table: "FileInfo", @@ -284,27 +281,12 @@ namespace osu.Game.Migrations name: "IX_RulesetInfo_Available", table: "RulesetInfo", column: "Available"); - - migrationBuilder.CreateIndex( - name: "IX_RulesetInfo_InstantiationInfo", - table: "RulesetInfo", - column: "InstantiationInfo", - unique: true); - - migrationBuilder.CreateIndex( - name: "IX_RulesetInfo_Name", - table: "RulesetInfo", - column: "Name", - unique: true); } protected override void Down(MigrationBuilder migrationBuilder) { migrationBuilder.DropTable( - name: "BeatmapDifficulty"); - - migrationBuilder.DropTable( - name: "BeatmapMetadata"); + name: "BeatmapInfo"); migrationBuilder.DropTable( name: "BeatmapSetFileInfo"); @@ -313,16 +295,19 @@ namespace osu.Game.Migrations name: "KeyBinding"); migrationBuilder.DropTable( - name: "BeatmapInfo"); + name: "BeatmapDifficulty"); migrationBuilder.DropTable( - name: "FileInfo"); + name: "RulesetInfo"); migrationBuilder.DropTable( name: "BeatmapSetInfo"); migrationBuilder.DropTable( - name: "RulesetInfo"); + name: "FileInfo"); + + migrationBuilder.DropTable( + name: "BeatmapMetadata"); } } } diff --git a/osu.Game/Migrations/OsuDbContextModelSnapshot.cs b/osu.Game/Migrations/OsuDbContextModelSnapshot.cs index 8d0d8f20fe..0576242648 100644 --- a/osu.Game/Migrations/OsuDbContextModelSnapshot.cs +++ b/osu.Game/Migrations/OsuDbContextModelSnapshot.cs @@ -25,8 +25,6 @@ namespace osu.Game.Migrations b.Property("ApproachRate"); - b.Property("BeatmapInfoID"); - b.Property("CircleSize"); b.Property("DrainRate"); @@ -39,9 +37,6 @@ namespace osu.Game.Migrations b.HasKey("ID"); - b.HasIndex("BeatmapInfoID") - .IsUnique(); - b.ToTable("BeatmapDifficulty"); }); @@ -72,6 +67,10 @@ namespace osu.Game.Migrations b.Property("MD5Hash"); + b.Property("MetadataID"); + + b.Property("OnlineBeatmapID"); + b.Property("Path"); b.Property("RulesetID"); @@ -92,12 +91,16 @@ namespace osu.Game.Migrations b.HasKey("ID"); + b.HasIndex("BaseDifficultyID"); + b.HasIndex("BeatmapSetInfoID"); b.HasIndex("Hash"); b.HasIndex("MD5Hash"); + b.HasIndex("MetadataID"); + b.HasIndex("RulesetID"); b.ToTable("BeatmapInfo"); @@ -119,10 +122,6 @@ namespace osu.Game.Migrations b.Property("BackgroundFile"); - b.Property("BeatmapInfoID"); - - b.Property("BeatmapSetInfoID"); - b.Property("PreviewTime"); b.Property("Source"); @@ -135,12 +134,6 @@ namespace osu.Game.Migrations b.HasKey("ID"); - b.HasIndex("BeatmapInfoID") - .IsUnique(); - - b.HasIndex("BeatmapSetInfoID") - .IsUnique(); - b.ToTable("BeatmapMetadata"); }); @@ -174,6 +167,8 @@ namespace osu.Game.Migrations b.Property("Hash"); + b.Property("MetadataID"); + b.Property("OnlineBeatmapSetID"); b.Property("Protected"); @@ -184,6 +179,8 @@ namespace osu.Game.Migrations b.HasIndex("Hash"); + b.HasIndex("MetadataID"); + b.ToTable("BeatmapSetInfo"); }); @@ -245,49 +242,31 @@ namespace osu.Game.Migrations b.HasIndex("Available"); - b.HasIndex("InstantiationInfo") - .IsUnique(); - - b.HasIndex("Name") - .IsUnique(); - b.ToTable("RulesetInfo"); }); - modelBuilder.Entity("osu.Game.Beatmaps.BeatmapDifficulty", b => - { - b.HasOne("osu.Game.Beatmaps.BeatmapInfo") - .WithOne("Difficulty") - .HasForeignKey("osu.Game.Beatmaps.BeatmapDifficulty", "BeatmapInfoID") - .OnDelete(DeleteBehavior.Cascade); - }); - modelBuilder.Entity("osu.Game.Beatmaps.BeatmapInfo", b => { + b.HasOne("osu.Game.Beatmaps.BeatmapDifficulty", "BaseDifficulty") + .WithMany() + .HasForeignKey("BaseDifficultyID") + .OnDelete(DeleteBehavior.Cascade); + b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo", "BeatmapSet") .WithMany("Beatmaps") .HasForeignKey("BeatmapSetInfoID") .OnDelete(DeleteBehavior.Cascade); + b.HasOne("osu.Game.Beatmaps.BeatmapMetadata", "Metadata") + .WithMany("Beatmaps") + .HasForeignKey("MetadataID"); + b.HasOne("osu.Game.Rulesets.RulesetInfo", "Ruleset") .WithMany() .HasForeignKey("RulesetID") .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity("osu.Game.Beatmaps.BeatmapMetadata", b => - { - b.HasOne("osu.Game.Beatmaps.BeatmapInfo", "BeatmapInfo") - .WithOne("Metadata") - .HasForeignKey("osu.Game.Beatmaps.BeatmapMetadata", "BeatmapInfoID") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo", "BeatmapSetInfo") - .WithOne("Metadata") - .HasForeignKey("osu.Game.Beatmaps.BeatmapMetadata", "BeatmapSetInfoID") - .OnDelete(DeleteBehavior.Cascade); - }); - modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetFileInfo", b => { b.HasOne("osu.Game.Beatmaps.BeatmapSetInfo") @@ -300,6 +279,13 @@ namespace osu.Game.Migrations .HasForeignKey("FileInfoID") .OnDelete(DeleteBehavior.Cascade); }); + + modelBuilder.Entity("osu.Game.Beatmaps.BeatmapSetInfo", b => + { + b.HasOne("osu.Game.Beatmaps.BeatmapMetadata", "Metadata") + .WithMany("BeatmapSets") + .HasForeignKey("MetadataID"); + }); #pragma warning restore 612, 618 } } diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index 729df02ffd..6f53b76031 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -172,11 +172,11 @@ namespace osu.Game.Rulesets.UI // Apply difficulty adjustments from mods before using Difficulty. foreach (var mod in Mods.OfType()) - mod.ApplyToDifficulty(Beatmap.BeatmapInfo.Difficulty); + mod.ApplyToDifficulty(Beatmap.BeatmapInfo.BaseDifficulty); // Apply defaults foreach (var h in Beatmap.HitObjects) - h.ApplyDefaults(Beatmap.ControlPointInfo, Beatmap.BeatmapInfo.Difficulty); + h.ApplyDefaults(Beatmap.ControlPointInfo, Beatmap.BeatmapInfo.BaseDifficulty); // Post-process the beatmap processor.PostProcess(Beatmap); diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index a98362e89c..d7c509d979 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -264,7 +264,7 @@ namespace osu.Game.Screens.Select advanced.Beatmap = new BeatmapInfo { StarDifficulty = 0, - Difficulty = new BeatmapDifficulty + BaseDifficulty = new BeatmapDifficulty { CircleSize = 0, DrainRate = 0, diff --git a/osu.Game/Screens/Select/Details/AdvancedStats.cs b/osu.Game/Screens/Select/Details/AdvancedStats.cs index f1215ab33d..3c9cffadfb 100644 --- a/osu.Game/Screens/Select/Details/AdvancedStats.cs +++ b/osu.Game/Screens/Select/Details/AdvancedStats.cs @@ -32,17 +32,17 @@ namespace osu.Game.Screens.Select.Details if ((Beatmap?.Ruleset?.ID ?? 0) == 3) { firstValue.Title = "Key Amount"; - firstValue.Value = (int)Math.Round(Beatmap?.Difficulty?.CircleSize ?? 0); + firstValue.Value = (int)Math.Round(Beatmap?.BaseDifficulty?.CircleSize ?? 0); } else { firstValue.Title = "Circle Size"; - firstValue.Value = Beatmap?.Difficulty?.CircleSize ?? 0; + firstValue.Value = Beatmap?.BaseDifficulty?.CircleSize ?? 0; } - hpDrain.Value = beatmap.Difficulty?.DrainRate ?? 0; - accuracy.Value = beatmap.Difficulty?.OverallDifficulty ?? 0; - approachRate.Value = beatmap.Difficulty?.ApproachRate ?? 0; + hpDrain.Value = beatmap.BaseDifficulty?.DrainRate ?? 0; + accuracy.Value = beatmap.BaseDifficulty?.OverallDifficulty ?? 0; + approachRate.Value = beatmap.BaseDifficulty?.ApproachRate ?? 0; starDifficulty.Value = (float)beatmap.StarDifficulty; } } diff --git a/osu.Game/Tests/Visual/TestCaseBeatmapDetails.cs b/osu.Game/Tests/Visual/TestCaseBeatmapDetails.cs index cd4d97425b..5306121a92 100644 --- a/osu.Game/Tests/Visual/TestCaseBeatmapDetails.cs +++ b/osu.Game/Tests/Visual/TestCaseBeatmapDetails.cs @@ -29,7 +29,7 @@ namespace osu.Game.Tests.Visual Source = "osu!lazer", Tags = "this beatmap has all the metrics", }, - Difficulty = new BeatmapDifficulty + BaseDifficulty = new BeatmapDifficulty { CircleSize = 7, DrainRate = 1, @@ -53,7 +53,7 @@ namespace osu.Game.Tests.Visual Source = "osu!lazer", Tags = "this beatmap has ratings metrics but not retries or fails", }, - Difficulty = new BeatmapDifficulty + BaseDifficulty = new BeatmapDifficulty { CircleSize = 6, DrainRate = 9, @@ -75,7 +75,7 @@ namespace osu.Game.Tests.Visual Source = "osu!lazer", Tags = "this beatmap has retries and fails but no ratings", }, - Difficulty = new BeatmapDifficulty + BaseDifficulty = new BeatmapDifficulty { CircleSize = 3.7f, DrainRate = 6, @@ -98,7 +98,7 @@ namespace osu.Game.Tests.Visual Source = "osu!lazer", Tags = "this beatmap has no metrics", }, - Difficulty = new BeatmapDifficulty + BaseDifficulty = new BeatmapDifficulty { CircleSize = 5, DrainRate = 5, diff --git a/osu.Game/Tests/Visual/TestCaseBeatmapSetOverlay.cs b/osu.Game/Tests/Visual/TestCaseBeatmapSetOverlay.cs index 72d97f905c..1ade0be626 100644 --- a/osu.Game/Tests/Visual/TestCaseBeatmapSetOverlay.cs +++ b/osu.Game/Tests/Visual/TestCaseBeatmapSetOverlay.cs @@ -65,7 +65,7 @@ namespace osu.Game.Tests.Visual StarDifficulty = 1.36, Version = @"BASIC", Ruleset = mania, - Difficulty = new BeatmapDifficulty + BaseDifficulty = new BeatmapDifficulty { CircleSize = 4, DrainRate = 6.5f, @@ -93,7 +93,7 @@ namespace osu.Game.Tests.Visual StarDifficulty = 2.22, Version = @"NOVICE", Ruleset = mania, - Difficulty = new BeatmapDifficulty + BaseDifficulty = new BeatmapDifficulty { CircleSize = 4, DrainRate = 7, @@ -121,7 +121,7 @@ namespace osu.Game.Tests.Visual StarDifficulty = 3.49, Version = @"ADVANCED", Ruleset = mania, - Difficulty = new BeatmapDifficulty + BaseDifficulty = new BeatmapDifficulty { CircleSize = 4, DrainRate = 7.5f, @@ -149,7 +149,7 @@ namespace osu.Game.Tests.Visual StarDifficulty = 4.24, Version = @"EXHAUST", Ruleset = mania, - Difficulty = new BeatmapDifficulty + BaseDifficulty = new BeatmapDifficulty { CircleSize = 4, DrainRate = 8, @@ -177,7 +177,7 @@ namespace osu.Game.Tests.Visual StarDifficulty = 5.26, Version = @"GRAVITY", Ruleset = mania, - Difficulty = new BeatmapDifficulty + BaseDifficulty = new BeatmapDifficulty { CircleSize = 4, DrainRate = 8.5f, @@ -239,7 +239,7 @@ namespace osu.Game.Tests.Visual StarDifficulty = 1.40, Version = @"yzrin's Kantan", Ruleset = taiko, - Difficulty = new BeatmapDifficulty + BaseDifficulty = new BeatmapDifficulty { CircleSize = 2, DrainRate = 7, @@ -267,7 +267,7 @@ namespace osu.Game.Tests.Visual StarDifficulty = 2.23, Version = @"Futsuu", Ruleset = taiko, - Difficulty = new BeatmapDifficulty + BaseDifficulty = new BeatmapDifficulty { CircleSize = 2, DrainRate = 6, @@ -295,7 +295,7 @@ namespace osu.Game.Tests.Visual StarDifficulty = 3.19, Version = @"Muzukashii", Ruleset = taiko, - Difficulty = new BeatmapDifficulty + BaseDifficulty = new BeatmapDifficulty { CircleSize = 2, DrainRate = 6, @@ -323,7 +323,7 @@ namespace osu.Game.Tests.Visual StarDifficulty = 3.97, Version = @"Charlotte's Oni", Ruleset = taiko, - Difficulty = new BeatmapDifficulty + BaseDifficulty = new BeatmapDifficulty { CircleSize = 5, DrainRate = 6, @@ -351,7 +351,7 @@ namespace osu.Game.Tests.Visual StarDifficulty = 5.08, Version = @"Labyrinth Oni", Ruleset = taiko, - Difficulty = new BeatmapDifficulty + BaseDifficulty = new BeatmapDifficulty { CircleSize = 5, DrainRate = 5, diff --git a/osu.Game/Tests/Visual/TestCasePlaySongSelect.cs b/osu.Game/Tests/Visual/TestCasePlaySongSelect.cs index a46542760b..965308c32c 100644 --- a/osu.Game/Tests/Visual/TestCasePlaySongSelect.cs +++ b/osu.Game/Tests/Visual/TestCasePlaySongSelect.cs @@ -80,7 +80,7 @@ namespace osu.Game.Tests.Visual Ruleset = rulesets.AvailableRulesets.First(), Path = "normal.osu", Version = "Normal", - Difficulty = new BeatmapDifficulty + BaseDifficulty = new BeatmapDifficulty { OverallDifficulty = 3.5f, } @@ -91,7 +91,7 @@ namespace osu.Game.Tests.Visual Ruleset = rulesets.AvailableRulesets.First(), Path = "hard.osu", Version = "Hard", - Difficulty = new BeatmapDifficulty + BaseDifficulty = new BeatmapDifficulty { OverallDifficulty = 5, } @@ -102,7 +102,7 @@ namespace osu.Game.Tests.Visual Ruleset = rulesets.AvailableRulesets.First(), Path = "insane.osu", Version = "Insane", - Difficulty = new BeatmapDifficulty + BaseDifficulty = new BeatmapDifficulty { OverallDifficulty = 7, } diff --git a/osu.Game/Tests/Visual/TestCaseScrollingPlayfield.cs b/osu.Game/Tests/Visual/TestCaseScrollingPlayfield.cs index d0761e5841..40fb22af1e 100644 --- a/osu.Game/Tests/Visual/TestCaseScrollingPlayfield.cs +++ b/osu.Game/Tests/Visual/TestCaseScrollingPlayfield.cs @@ -48,7 +48,7 @@ namespace osu.Game.Tests.Visual HitObjects = objects, BeatmapInfo = new BeatmapInfo { - Difficulty = new BeatmapDifficulty(), + BaseDifficulty = new BeatmapDifficulty(), Metadata = new BeatmapMetadata() } }; diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 0e16c70277..85b08afecd 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -281,9 +281,9 @@ - - - 20171018125509_InitialCreate.cs + + + 20171019041408_InitialCreate.cs