Skip to content

Commit

Permalink
Remove the default karaoke skin.
Browse files Browse the repository at this point in the history
Because need to read the config from the karaoke skin.
So use tricky way to fix the test case broken.
Technically, should be better to use the skin transformer ;_;
  • Loading branch information
andy840119 committed Oct 10, 2022
1 parent 37cc22f commit 2f92d07
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 43 deletions.
38 changes: 37 additions & 1 deletion osu.Game.Rulesets.Karaoke.Tests/Editor/TestSceneLayoutToolTip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@

using System;
using System.Collections.Generic;
using JetBrains.Annotations;
using NUnit.Framework;
using osu.Framework.Graphics;
using osu.Game.IO;
using osu.Game.Rulesets.Karaoke.Edit.Components.Cursor;
using osu.Game.Rulesets.Karaoke.Extensions;
using osu.Game.Rulesets.Karaoke.Objects;
using osu.Game.Rulesets.Karaoke.Skinning;
using osu.Game.Rulesets.Karaoke.Skinning.Elements;
using osu.Game.Skinning;
using osu.Game.Tests.Visual;

Expand All @@ -16,7 +20,7 @@ namespace osu.Game.Rulesets.Karaoke.Tests.Editor
[TestFixture]
public class TestSceneLayoutToolTip : OsuTestScene
{
private readonly ISkin skin = new DefaultKaraokeSkin(null);
private ISkin skin = new TestingSkin(null);
private LayoutToolTip toolTip = null!;

[SetUp]
Expand Down Expand Up @@ -62,5 +66,37 @@ private void setTooltip(string testName, Action<Lyric> callBack)
toolTip.SetContent(singer);
});
}

/// <summary>
/// todo: it's a tricky way to create ruleset's own skin class.
/// should use generic skin like <see cref="LegacySkin"/> eventually.
/// </summary>
public class TestingSkin : KaraokeSkin
{
internal static readonly Guid DEFAULT_SKIN = new("FEC5A291-5709-11EC-9F10-0800200C9A66");

public static SkinInfo CreateInfo() => new()
{
ID = DEFAULT_SKIN,
Name = "karaoke! (default skin)",
Creator = "team karaoke!",
Protected = true,
InstantiationInfo = typeof(TestingSkin).GetInvariantInstantiationInfo()
};

public TestingSkin(IStorageResourceProvider? resources)
: this(CreateInfo(), resources)
{
}

[UsedImplicitly(ImplicitUseKindFlags.InstantiatedWithFixedConstructorSignature)]
public TestingSkin(SkinInfo skin, IStorageResourceProvider? resources)
: base(skin, resources)
{
DefaultElement[ElementType.LyricConfig] = LyricConfig.CreateDefault();
DefaultElement[ElementType.LyricStyle] = LyricStyle.CreateDefault();
DefaultElement[ElementType.NoteStyle] = NoteStyle.CreateDefault();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence.
// See the LICENCE file in the repository root for full licence text.

using System;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Game.Database;
using osu.Game.IO;
using osu.Game.Rulesets.Karaoke.Beatmaps;
using osu.Game.Rulesets.Karaoke.Extensions;
using osu.Game.Rulesets.Karaoke.Screens.Skin;
using osu.Game.Rulesets.Karaoke.Skinning;
using osu.Game.Rulesets.Karaoke.Skinning.Elements;
using osu.Game.Screens.Edit;
using osu.Game.Skinning;

Expand All @@ -28,11 +33,43 @@ public class TestSceneKaraokeSkinEditor : ScreenTestScene<KaraokeSkinEditor>
[BackgroundDependencyLoader]
private void load(SkinManager skinManager)
{
skinManager.CurrentSkinInfo.Value = DefaultKaraokeSkin.CreateInfo().ToLiveUnmanaged();
skinManager.CurrentSkinInfo.Value = TestingSkin.CreateInfo().ToLiveUnmanaged();

karaokeSkin = skinManager.CurrentSkin.Value as KaraokeSkin;
}

protected override KaraokeSkinEditor CreateScreen() => new(karaokeSkin);

/// <summary>
/// todo: it's a tricky way to create ruleset's own skin class.
/// should use generic skin like <see cref="LegacySkin"/> eventually.
/// </summary>
public class TestingSkin : KaraokeSkin
{
internal static readonly Guid DEFAULT_SKIN = new("FEC5A291-5709-11EC-9F10-0800200C9A66");

public static SkinInfo CreateInfo() => new()
{
ID = DEFAULT_SKIN,
Name = "karaoke! (default skin)",
Creator = "team karaoke!",
Protected = true,
InstantiationInfo = typeof(TestingSkin).GetInvariantInstantiationInfo()
};

public TestingSkin(IStorageResourceProvider? resources)
: this(CreateInfo(), resources)
{
}

[UsedImplicitly(ImplicitUseKindFlags.InstantiatedWithFixedConstructorSignature)]
public TestingSkin(SkinInfo skin, IStorageResourceProvider? resources)
: base(skin, resources)
{
DefaultElement[ElementType.LyricConfig] = LyricConfig.CreateDefault();
DefaultElement[ElementType.LyricStyle] = LyricStyle.CreateDefault();
DefaultElement[ElementType.NoteStyle] = NoteStyle.CreateDefault();
}
}
}
}
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Karaoke/Edit/Lyrics/LyricEditorSkin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class LyricEditorSkin : KaraokeSkin
Name = "karaoke! (default editor skin)",
Creator = "team karaoke!",
Protected = true,
InstantiationInfo = typeof(DefaultKaraokeSkin).GetInvariantInstantiationInfo(),
InstantiationInfo = typeof(LyricEditorSkin).GetInvariantInstantiationInfo(),
};

public LyricEditorSkin(IStorageResourceProvider? resources)
Expand Down
40 changes: 0 additions & 40 deletions osu.Game.Rulesets.Karaoke/Skinning/DefaultKaraokeSkin.cs

This file was deleted.

0 comments on commit 2f92d07

Please sign in to comment.