diff --git a/osu.Game.Rulesets.Karaoke.Tests/TestSceneSaitenAdjustmentScreen.cs b/osu.Game.Rulesets.Karaoke.Tests/TestSceneSaitenAdjustmentScreen.cs new file mode 100644 index 000000000..4c0a2a6f7 --- /dev/null +++ b/osu.Game.Rulesets.Karaoke.Tests/TestSceneSaitenAdjustmentScreen.cs @@ -0,0 +1,26 @@ +// 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.Rulesets.Karaoke.Screens.SaitenAdjustment; +using osu.Game.Screens; +using osu.Game.Tests.Visual; + +namespace osu.Game.Rulesets.Karaoke.Tests +{ + public class TestSceneSaitenAdjustmentScreen : OsuTestScene + { + private OsuScreenStack stack; + private SaitenAdjustmentScreen saitenAdjustmentScreen; + + [SetUp] + public virtual void SetUp() => Schedule(() => + { + var stack = new OsuScreenStack { RelativeSizeAxes = Axes.Both }; + Child = stack; + + stack.Push(saitenAdjustmentScreen = new SaitenAdjustmentScreen()); + }); + } +} diff --git a/osu.Game.Rulesets.Karaoke.Tests/osu.Game.Rulesets.Karaoke.Tests.csproj b/osu.Game.Rulesets.Karaoke.Tests/osu.Game.Rulesets.Karaoke.Tests.csproj index 7873f6303..3385311da 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/osu.Game.Rulesets.Karaoke.Tests.csproj +++ b/osu.Game.Rulesets.Karaoke.Tests/osu.Game.Rulesets.Karaoke.Tests.csproj @@ -19,9 +19,6 @@ - - - diff --git a/osu.Game.Rulesets.Karaoke/Resources/Beatmaps/saiten-result.osu b/osu.Game.Rulesets.Karaoke/Resources/Beatmaps/saiten-result.osu new file mode 100644 index 000000000..966f3b97b --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Resources/Beatmaps/saiten-result.osu @@ -0,0 +1,58 @@ +karaoke file format v1 + +[General] +AudioFilename: saiten-adjustment.mp3 +AudioLeadIn: 0 +PreviewTime: 0 +Countdown: 0 +SampleSet: Normal +StackLeniency: 1 +Mode: 111 +LetterboxInBreaks: 0 +WidescreenStoryboard: 1 + +[Editor] +DistanceSpacing: 1 +BeatDivisor: 4 +GridSize: 4 +TimelineZoom: 1 + +[Metadata] +Title:Saiten result display +TitleUnicode:Saiten result display +Artist:andy840119 +ArtistUnicode:andy840119 +Creator:andy840119 +Version:Normal +Source:andy840119 +Tags:karaoke +BeatmapID:1 +BeatmapSetID:1 + +[Difficulty] +HPDrainRate:2 +CircleSize:3 +OverallDifficulty:2 +ApproachRate:4 +SliderMultiplier:0.8 +SliderTickRate:1 + +[Events] +//Background and Video events +Video,0,"video.mp4" +0,0,"bg.png",0,0 + +[Colours] + +[HitObjects] +@[00:00:00]Ra[00:01:00]Ra#[00:02:00]Ra[00:03:00]Ra#[00:04:00]Ra[00:05:00]Ra#[00:06:00]Ra[00:07:00]Ra#[00:08:00]Ra[00:09:00] +@note1=0,0#,1,1#,2,2#,3,3#,4 +@[00:15:00]Ra[00:16:00]Ra#[00:17:00]Ra[00:18:00]Ra#[00:19:00]Ra[00:20:00]Ra#[00:21:00]Ra[00:22:00]Ra#[00:23:00]Ra[00:24:00] +@note1=4,3#,3,2#,2,1#,1,0#,0 + +@[00:30:00]Ra[00:31:00]Ra#[00:32:00]Ra[00:33:00]Ra#[00:34:00]Ra[00:35:00]Ra#[00:36:00]Ra[00:37:00]Ra#[00:38:00]Ra[00:39:00] +@note1=0,-1#,-1,-2#,-2,-3#,-3,-4#,-4 +@[00:45:00]Ra[00:46:00]Ra#[00:47:00]Ra[00:48:00]Ra#[00:49:00]Ra[00:50:00]Ra#[00:51:00]Ra[00:52:00]Ra#[00:53:00]Ra[00:54:00] +@note1=-4,-4#,-3,-3#,-2,-2#,-1,-1#,0 + +end \ No newline at end of file diff --git a/osu.Game.Rulesets.Karaoke/Resources/KaraokeResources.cs b/osu.Game.Rulesets.Karaoke/Resources/KaraokeResources.cs new file mode 100644 index 000000000..6f1fa6434 --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Resources/KaraokeResources.cs @@ -0,0 +1,30 @@ +// Copyright (c) andy840119 . Licensed under the GPL Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.IO; +using osu.Framework.IO.Stores; +using osu.Game.Beatmaps; +using osu.Game.Beatmaps.Formats; +using osu.Game.IO; + +namespace osu.Game.Rulesets.Karaoke.Resources +{ + public static class KaraokeResources + { + public static DllResourceStore GetStore() => new DllResourceStore(typeof(KaraokeResources).Assembly); + + public static Stream OpenResource(string name) => GetStore().GetStream($"Resources/{name}"); + + public static Stream OpenBeatmapResource(string name) => OpenResource($"Beatmaps/{name}.osu"); + + public static Beatmap OpenBeatmap(string name) + { + using (var resStream = OpenBeatmapResource(name)) + using (var stream = new LineBufferedReader(resStream)) + { + var decoder = Decoder.GetDecoder(stream); + return decoder.Decode(stream); + } + } + } +} diff --git a/osu.Game.Rulesets.Karaoke/Screens/SaitenAdjustment/Beatmaps/SaitenAdjustmentWorkingBeatmap.cs b/osu.Game.Rulesets.Karaoke/Screens/SaitenAdjustment/Beatmaps/SaitenAdjustmentWorkingBeatmap.cs new file mode 100644 index 000000000..ea40586dd --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Screens/SaitenAdjustment/Beatmaps/SaitenAdjustmentWorkingBeatmap.cs @@ -0,0 +1,27 @@ +// Copyright (c) andy840119 . Licensed under the GPL Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Audio.Track; +using osu.Framework.Graphics.Textures; +using osu.Game.Beatmaps; + +namespace osu.Game.Rulesets.Karaoke.Screens.SaitenAdjustment.Beatmaps +{ + public class SaitenAdjustmentWorkingBeatmap : WorkingBeatmap + { + private readonly IBeatmap beatmap; + + public SaitenAdjustmentWorkingBeatmap(IBeatmap beatmap) + : base(beatmap.BeatmapInfo, null) + { + this.beatmap = beatmap; + } + + protected override Texture GetBackground() => null; + + protected override IBeatmap GetBeatmap() => beatmap; + + // TODO : get real track from resource + protected override Track GetTrack() => AudioManager.Tracks.GetVirtual(10000); + } +} diff --git a/osu.Game.Rulesets.Karaoke/Screens/SaitenAdjustment/SaitenAdjustmentScreen.cs b/osu.Game.Rulesets.Karaoke/Screens/SaitenAdjustment/SaitenAdjustmentScreen.cs new file mode 100644 index 000000000..5fbb29358 --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Screens/SaitenAdjustment/SaitenAdjustmentScreen.cs @@ -0,0 +1,28 @@ +// Copyright (c) andy840119 . Licensed under the GPL Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Rulesets.Karaoke.Screens.SaitenAdjustment.UI; +using osu.Game.Screens; + +namespace osu.Game.Rulesets.Karaoke.Screens.SaitenAdjustment +{ + public class SaitenAdjustmentScreen : OsuScreen + { + public SaitenAdjustmentScreen() + { + AddInternal(new Container + { + RelativeSizeAxes = Axes.Both, + Children = new[] + { + new SaitenAdjustmentVisualization("saiten-result") + { + RelativeSizeAxes = Axes.Both + } + } + }); + } + } +} diff --git a/osu.Game.Rulesets.Karaoke/Screens/SaitenAdjustment/UI/SaitenAdjustmentVisualization.cs b/osu.Game.Rulesets.Karaoke/Screens/SaitenAdjustment/UI/SaitenAdjustmentVisualization.cs new file mode 100644 index 000000000..9966bf48b --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Screens/SaitenAdjustment/UI/SaitenAdjustmentVisualization.cs @@ -0,0 +1,69 @@ +// Copyright (c) andy840119 . Licensed under the GPL Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Game.Beatmaps; +using osu.Game.Rulesets.Karaoke.Objects; +using osu.Game.Rulesets.Karaoke.Objects.Drawables; +using osu.Game.Rulesets.Karaoke.UI; +using osu.Game.Rulesets.Mods; +using osu.Game.Rulesets.Objects.Drawables; +using System.Collections.Generic; +using osu.Framework.Graphics.Containers; +using osu.Game.Rulesets.Karaoke.Resources; +using osu.Game.Rulesets.Karaoke.Screens.SaitenAdjustment.Beatmaps; +using osu.Framework.Graphics; +using osu.Game.Skinning; +using osu.Game.Rulesets.Karaoke.Skinning; + +namespace osu.Game.Rulesets.Karaoke.Screens.SaitenAdjustment.UI +{ + public class SaitenAdjustmentVisualization : Container + { + private readonly string beatmapName; + private DrawableSaitenAdjustmentRuleset drawableRuleset; + + public SaitenAdjustmentVisualization(string resourcesBeatmapName) + { + beatmapName = resourcesBeatmapName; + + // Get karaoke ruleset + var ruleset = new KaraokeRuleset(); + + // Create beatmap + var beatmap = KaraokeResources.OpenBeatmap(beatmapName); + var workingBeatmap = new SaitenAdjustmentWorkingBeatmap(beatmap); + var convertedBeatmap = workingBeatmap.GetPlayableBeatmap(ruleset.RulesetInfo); + + // Create skin + var skin = new KaraokeLegacySkinTransformer(null); + + Children = new[] + { + new SkinProvidingContainer(skin) + { + Child = drawableRuleset = new DrawableSaitenAdjustmentRuleset(ruleset, convertedBeatmap, null) + { + RelativeSizeAxes = Axes.Both + } + } + }; + } + + private class DrawableSaitenAdjustmentRuleset : DrawableKaraokeRuleset + { + public DrawableSaitenAdjustmentRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList mods) + : base(ruleset, beatmap, mods) + { + // Hide lyric playfield + Playfield.LyricPlayfield.Hide(); + } + + public override DrawableHitObject CreateDrawableRepresentation(KaraokeHitObject h) + { + // Only get drawable note here + var drawableHitObject = base.CreateDrawableRepresentation(h); + return drawableHitObject is DrawableNote ? drawableHitObject : null; + } + } + } +} diff --git a/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj b/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj index 8f825589f..6ec07645c 100644 --- a/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj +++ b/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj @@ -9,6 +9,9 @@ + + +