From 1e895b7438c910c105ce30624e7e07998953db93 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Wed, 9 Sep 2020 22:15:58 +0900 Subject: [PATCH 1/3] Display singer and note. --- .../Beatmaps/KaraokeBeatmap.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmap.cs b/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmap.cs index aa5f93cf3..0b2ec1e7c 100644 --- a/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmap.cs +++ b/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmap.cs @@ -13,15 +13,29 @@ public class KaraokeBeatmap : Beatmap { public override IEnumerable GetStatistics() { + int singers = 1; int lyrics = HitObjects.Count(s => s is LyricLine); + int notes = HitObjects.Count(s => s is Note); return new[] { + new BeatmapStatistic + { + Name = @"Singer", + Content = singers.ToString(), + Icon = FontAwesome.Solid.User + }, new BeatmapStatistic { Name = @"Lyric", Content = lyrics.ToString(), - Icon = FontAwesome.Regular.Circle + Icon = FontAwesome.Solid.AlignLeft + }, + new BeatmapStatistic + { + Name = @"Note", + Content = notes.ToString(), + Icon = FontAwesome.Solid.Music }, }; } From bc9328f610f809630fb80b8bb694e179a63f14fa Mon Sep 17 00:00:00 2001 From: andy840119 Date: Wed, 9 Sep 2020 22:45:30 +0900 Subject: [PATCH 2/3] Add test case(without checking result.) --- .../Beatmaps/TestSceneBeatmapInfoWedge.cs | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 osu.Game.Rulesets.Karaoke.Tests/Beatmaps/TestSceneBeatmapInfoWedge.cs diff --git a/osu.Game.Rulesets.Karaoke.Tests/Beatmaps/TestSceneBeatmapInfoWedge.cs b/osu.Game.Rulesets.Karaoke.Tests/Beatmaps/TestSceneBeatmapInfoWedge.cs new file mode 100644 index 000000000..1b9d96949 --- /dev/null +++ b/osu.Game.Rulesets.Karaoke.Tests/Beatmaps/TestSceneBeatmapInfoWedge.cs @@ -0,0 +1,72 @@ +// Copyright (c) andy840119 . Licensed under the GPL Licence. +// See the LICENCE file in the repository root for full licence text. + +using NUnit.Framework; +using osu.Framework.Graphics; +using osu.Game.Beatmaps; +using osu.Game.Beatmaps.Formats; +using osu.Game.IO; +using osu.Game.Rulesets.Karaoke.Tests.Resources; +using osu.Game.Screens.Select; +using osu.Game.Tests.Visual; +using osuTK; + +namespace osu.Game.Rulesets.Karaoke.Tests.Beatmaps +{ + [TestFixture] + public class TestSceneBeatmapInfoWedge : OsuTestScene + { + private TestBeatmapInfoWedge infoWedge; + protected override void LoadComplete() + { + base.LoadComplete(); + + Add(infoWedge = new TestBeatmapInfoWedge + { + Size = new Vector2(0.5f, 245), + RelativeSizeAxes = Axes.X, + Margin = new MarginPadding { Top = 20 } + }); + + AddStep("show", () => + { + infoWedge.Show(); + infoWedge.Beatmap = Beatmap.Value; + }); + } + + [TestCase("karaoke-file-samples")] + [TestCase("karaoke-file-samples-without-note")] + [TestCase("karaoke-note-samples")] + [TestCase("karaoke-style-samples")] + [TestCase("karaoke-translate-samples")] + public void TestNullBeatmap(string fileName) + { + using (var resStream = TestResources.OpenBeatmapResource(fileName)) + using (var stream = new LineBufferedReader(resStream)) + { + var decoder = Decoder.GetDecoder(stream); + var beatmap = decoder.Decode(stream); + selectBeatmap(beatmap, fileName); + } + } + + private void selectBeatmap(IBeatmap b, string fileName) + { + BeatmapInfoWedge.BufferedWedgeInfo infoBefore = null; + + AddStep($"select {b?.Metadata.Title ?? fileName} beatmap", () => + { + infoBefore = infoWedge.Info; + infoWedge.Beatmap = Beatmap.Value = b == null ? Beatmap.Default : CreateWorkingBeatmap(b); + }); + + AddUntilStep("wait for async load", () => infoWedge.Info != infoBefore); + } + + private class TestBeatmapInfoWedge : BeatmapInfoWedge + { + public new BufferedWedgeInfo Info => base.Info; + } + } +} From 5e96ed12b8b3a3fe7ed5992004a85c4fd5a2e177 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Fri, 11 Sep 2020 10:50:21 +0900 Subject: [PATCH 3/3] Adjust beatmap statistic. --- .../Beatmaps/KaraokeBeatmap.cs | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmap.cs b/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmap.cs index 0b2ec1e7c..4b5dd09a5 100644 --- a/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmap.cs +++ b/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmap.cs @@ -15,29 +15,33 @@ public override IEnumerable GetStatistics() { int singers = 1; int lyrics = HitObjects.Count(s => s is LyricLine); - int notes = HitObjects.Count(s => s is Note); - return new[] + var defaultStatistic = new List { new BeatmapStatistic { Name = @"Singer", Content = singers.ToString(), - Icon = FontAwesome.Solid.User + CreateIcon = () => new SpriteIcon { Icon = FontAwesome.Solid.User } }, new BeatmapStatistic { Name = @"Lyric", Content = lyrics.ToString(), - Icon = FontAwesome.Solid.AlignLeft + CreateIcon = () => new SpriteIcon { Icon = FontAwesome.Solid.AlignLeft } }, - new BeatmapStatistic + }; + + int notes = HitObjects.Count(s => s is Note note && note.Display); + if (notes > 0) + defaultStatistic.Add(new BeatmapStatistic { Name = @"Note", Content = notes.ToString(), - Icon = FontAwesome.Solid.Music - }, - }; + CreateIcon = () => new SpriteIcon { Icon = FontAwesome.Solid.Music } + }); + + return defaultStatistic.ToArray(); } } }