Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement saiten adjustment screen #38

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
26 changes: 26 additions & 0 deletions osu.Game.Rulesets.Karaoke.Tests/TestSceneSaitenAdjustmentScreen.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) andy840119 <[email protected]>. 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());
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
<PackageReference Include="NUnit3TestAdapter" Version="3.15.1" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Remove="Resources\TestResources.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\osu.Game.Rulesets.Karaoke\osu.Game.Rulesets.Karaoke.csproj" />
</ItemGroup>
Expand Down
58 changes: 58 additions & 0 deletions osu.Game.Rulesets.Karaoke/Resources/Beatmaps/saiten-result.osu
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions osu.Game.Rulesets.Karaoke/Resources/KaraokeResources.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) andy840119 <[email protected]>. 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<Beatmap>(stream);
return decoder.Decode(stream);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) andy840119 <[email protected]>. 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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright (c) andy840119 <[email protected]>. 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
}
}
});
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Copyright (c) andy840119 <[email protected]>. 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<Mod> mods)
: base(ruleset, beatmap, mods)
{
// Hide lyric playfield
Playfield.LyricPlayfield.Hide();
}

public override DrawableHitObject<KaraokeHitObject> CreateDrawableRepresentation(KaraokeHitObject h)
{
// Only get drawable note here
var drawableHitObject = base.CreateDrawableRepresentation(h);
return drawableHitObject is DrawableNote ? drawableHitObject : null;
}
}
}
}
3 changes: 3 additions & 0 deletions osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<ItemGroup>
<EmbeddedResource Include="Resources\**" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Remove="Resources\TestResources.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="osu.Framework.Microphone" Version="1.0.4" />
<PackageReference Include="ppy.osu.Game" Version="2020.408.1" />
Expand Down