public void TestSorted(int[] orders, int[] actualOrders) { var objects = orders?.Select(x => new TestOrderObject { Order = x }); var orderedArray = OrderUtils.Sorted(objects); var result = orderedArray?.Select(x => x.Order).ToArray(); Assert.AreEqual(result, actualOrders); }
private void load(EditorBeatmap beatmap) { // load lyric in here var lyrics = OrderUtils.Sorted(beatmap.HitObjects.OfType <Lyric>()); BindableLyrics.AddRange(lyrics); // need to check is there any lyric added or removed. beatmap.HitObjectAdded += e => { if (e is Lyric lyric) { var previousLyric = BindableLyrics.LastOrDefault(x => x.Order < lyric.Order); if (previousLyric != null) { var insertIndex = BindableLyrics.IndexOf(previousLyric) + 1; BindableLyrics.Insert(insertIndex, lyric); } else { // insert to first. BindableLyrics.Insert(0, lyric); } createAlgorithmList(); } }; beatmap.HitObjectRemoved += e => { if (e is Lyric lyric) { BindableLyrics.Remove(lyric); createAlgorithmList(); } }; // create algorithm set createAlgorithmList(); }
protected CaretPositionAlgorithm(Lyric[] lyrics) { Lyrics = LyricsUtils.FindUnlockLyrics(OrderUtils.Sorted(lyrics)); }