From 3e0e01abdb6f75ba2d05c0dc9c712160e426d11f Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 23 Nov 2021 01:02:22 +0900 Subject: [PATCH] Move bookmark parsing logic into `LegacyBeatmapDecoder` --- osu.Game/Beatmaps/BeatmapInfo.cs | 23 ------------------- .../Beatmaps/Formats/LegacyBeatmapDecoder.cs | 6 ++++- 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapInfo.cs b/osu.Game/Beatmaps/BeatmapInfo.cs index d2b322a843..782944c28e 100644 --- a/osu.Game/Beatmaps/BeatmapInfo.cs +++ b/osu.Game/Beatmaps/BeatmapInfo.cs @@ -5,7 +5,6 @@ using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using System.Linq; using Newtonsoft.Json; using osu.Framework.Testing; using osu.Game.Database; @@ -104,28 +103,6 @@ namespace osu.Game.Beatmaps /// public int CountdownOffset { get; set; } - // Editor - // This bookmarks stuff is necessary because DB doesn't know how to store int[] - [JsonIgnore] - public string StoredBookmarks - { - get => string.Join(',', Bookmarks); - set - { - if (string.IsNullOrEmpty(value)) - { - Bookmarks = Array.Empty(); - return; - } - - Bookmarks = value.Split(',').Select(v => - { - bool result = int.TryParse(v, out int val); - return new { result, val }; - }).Where(p => p.result).Select(p => p.val).ToArray(); - } - } - [NotMapped] public int[] Bookmarks { get; set; } = Array.Empty(); diff --git a/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs b/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs index 65d050e608..e5db9d045a 100644 --- a/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs +++ b/osu.Game/Beatmaps/Formats/LegacyBeatmapDecoder.cs @@ -201,7 +201,11 @@ namespace osu.Game.Beatmaps.Formats switch (pair.Key) { case @"Bookmarks": - beatmap.BeatmapInfo.StoredBookmarks = pair.Value; + beatmap.BeatmapInfo.Bookmarks = pair.Value.Split(',').Select(v => + { + bool result = int.TryParse(v, out int val); + return new { result, val }; + }).Where(p => p.result).Select(p => p.val).ToArray(); break; case @"DistanceSpacing":