From 9d348c0aaaaee01874349dd9dd18a55f42e156ab Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 1 Aug 2020 11:59:09 +0900 Subject: [PATCH 1/6] Add initial test case and some basic status. --- .../UI/TestCaseSaitenStatus.cs | 29 ++++++++ .../UI/Components/SaitenStatus.cs | 73 +++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 osu.Game.Rulesets.Karaoke.Tests/UI/TestCaseSaitenStatus.cs create mode 100644 osu.Game.Rulesets.Karaoke/UI/Components/SaitenStatus.cs diff --git a/osu.Game.Rulesets.Karaoke.Tests/UI/TestCaseSaitenStatus.cs b/osu.Game.Rulesets.Karaoke.Tests/UI/TestCaseSaitenStatus.cs new file mode 100644 index 000000000..26b0fb6b0 --- /dev/null +++ b/osu.Game.Rulesets.Karaoke.Tests/UI/TestCaseSaitenStatus.cs @@ -0,0 +1,29 @@ +// 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.Game.Rulesets.Karaoke.UI.Components; +using osu.Game.Tests.Visual; + +namespace osu.Game.Rulesets.Karaoke.Tests.UI +{ + [TestFixture] + public class TestCaseSaitenStatus : OsuTestScene + { + [TestCase(SaitenStatusMode.AndroidMicrophonePermissionDeclined)] + [TestCase(SaitenStatusMode.AndroidDoesNotSupported)] + [TestCase(SaitenStatusMode.IOSMicrophonePermissionDeclined)] + [TestCase(SaitenStatusMode.IOSDoesNotSupported)] + [TestCase(SaitenStatusMode.OSXMicrophonePermissionDeclined)] + [TestCase(SaitenStatusMode.OSXDoesNotSupported)] + [TestCase(SaitenStatusMode.WindowsMicrophonePermissionDeclined)] + [TestCase(SaitenStatusMode.Saitening)] + public void TestMode(SaitenStatusMode mode) + { + AddStep("create mod display", () => + { + Child = new SaitenStatus(mode); + }); + } + } +} diff --git a/osu.Game.Rulesets.Karaoke/UI/Components/SaitenStatus.cs b/osu.Game.Rulesets.Karaoke/UI/Components/SaitenStatus.cs new file mode 100644 index 000000000..0a7e7f2da --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/UI/Components/SaitenStatus.cs @@ -0,0 +1,73 @@ +// Copyright (c) andy840119 . Licensed under the GPL Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.ComponentModel; + +namespace osu.Game.Rulesets.Karaoke.UI.Components +{ + public class SaitenStatus : Framework.Graphics.Containers.Container + { + public SaitenStatus(SaitenStatusMode statusMode) + { + } + } + + public enum SaitenStatusMode + { + /// + /// Due to android device does not authorize microphone access. + /// + [Description("Android permission declined")] + AndroidMicrophonePermissionDeclined, + + /// + /// Saiten system does not support android device. + /// Will throw this if osu.framework.microphone does not supportu it yet. + /// Or official client does not open this permission. + /// + [Description("Android target not supported")] + AndroidDoesNotSupported, + + /// + /// Due to iOS device does not authorize microphone access. + /// + [Description("iOS permission declined")] + IOSMicrophonePermissionDeclined, + + /// + /// Saiten system does not support iOS device. + /// Will throw this if osu.framework.microphone does not supportu it yet. + /// Or official client does not open this permission. + /// + [Description("iOS target not supported")] + IOSDoesNotSupported, + + /// + /// Due to osx device does not authorize microphone access. + /// + [Description("osx permission declined")] + OSXMicrophonePermissionDeclined, + + /// + /// Saiten system does not support osx device. + /// Will throw this if osu.framework.microphone does not supportu it yet. + /// Or official client does not open this permission. + /// + [Description("osx target not supported")] + OSXDoesNotSupported, + + /// + /// Due to windows device does not authorize microphone access. + /// Windows client don't need to ask permission. + /// Open lazer client with admin permission can solve that. + /// + [Description("Windows permission declined")] + WindowsMicrophonePermissionDeclined, + + /// + /// Everything works well. + /// + [Description("Saitening...")] + Saitening, + } +} From b4ce58b6aaf2b2b0bdde3cc5ca61a71e36ebbda2 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 1 Aug 2020 12:47:39 +0900 Subject: [PATCH 2/6] Implement base saiten style. --- .../UI/TestCaseSaitenStatus.cs | 7 +- .../UI/Components/SaitenStatus.cs | 73 ++++++++++++++++++- 2 files changed, 78 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/UI/TestCaseSaitenStatus.cs b/osu.Game.Rulesets.Karaoke.Tests/UI/TestCaseSaitenStatus.cs index 26b0fb6b0..55940bc8b 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/UI/TestCaseSaitenStatus.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/UI/TestCaseSaitenStatus.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using NUnit.Framework; +using osu.Framework.Graphics; using osu.Game.Rulesets.Karaoke.UI.Components; using osu.Game.Tests.Visual; @@ -22,7 +23,11 @@ public void TestMode(SaitenStatusMode mode) { AddStep("create mod display", () => { - Child = new SaitenStatus(mode); + Child = new SaitenStatus(mode) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre + }; }); } } diff --git a/osu.Game.Rulesets.Karaoke/UI/Components/SaitenStatus.cs b/osu.Game.Rulesets.Karaoke/UI/Components/SaitenStatus.cs index 0a7e7f2da..92382eae4 100644 --- a/osu.Game.Rulesets.Karaoke/UI/Components/SaitenStatus.cs +++ b/osu.Game.Rulesets.Karaoke/UI/Components/SaitenStatus.cs @@ -1,14 +1,85 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. +using Markdig.Syntax; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Containers.Markdown; +using osu.Framework.Graphics.Sprites; +using osuTK; +using osuTK.Graphics; using System.ComponentModel; +using System.Linq; namespace osu.Game.Rulesets.Karaoke.UI.Components { - public class SaitenStatus : Framework.Graphics.Containers.Container + [Cached(Type = typeof(IMarkdownTextComponent))] + public class SaitenStatus : FillFlowContainer, IMarkdownTextComponent { + private const float size = 22; + + private Drawable CreateIcon(bool saitenable) => new SpriteIcon + { + Size = new Vector2(size), + Icon = saitenable ? FontAwesome.Regular.DotCircle : FontAwesome.Regular.PauseCircle, + Colour = saitenable ? Color4.Red : Color4.LightGray + }; + + private Drawable CreateStatusSpriteText(string markdownText) => new StatusSpriteText(markdownText) + { + RelativeSizeAxes = Axes.None, + AutoSizeAxes = Axes.Both + }; + + public SpriteText CreateSpriteText() => new SpriteText(); + public SaitenStatus(SaitenStatusMode statusMode) { + Spacing = new Vector2(5); + Direction = FillDirection.Horizontal; + AutoSizeAxes = Axes.Both; + Children = new Drawable[] + { + CreateIcon(statusMode == SaitenStatusMode.Saitening), + CreateStatusSpriteText(GetSaitenStatusText(statusMode)) + }; + } + + protected virtual string GetSaitenStatusText(SaitenStatusMode statusMode) + { + switch (statusMode) + { + case SaitenStatusMode.AndroidMicrophonePermissionDeclined: + return "Go to setting to open permission for lazer."; + case SaitenStatusMode.AndroidDoesNotSupported: + return "Android device haven't support saiten system yet :("; + case SaitenStatusMode.IOSMicrophonePermissionDeclined: + return "Go to setting to open permission for lazer."; + case SaitenStatusMode.IOSDoesNotSupported: + return "iOS device haven't support saiten system yet :("; + case SaitenStatusMode.OSXMicrophonePermissionDeclined: + return "Go to setting to open permission for lazer."; + case SaitenStatusMode.OSXDoesNotSupported: + return "Osx device haven't support saiten system yet :("; + case SaitenStatusMode.WindowsMicrophonePermissionDeclined: + return "Open lazer with admin permission to enable saiten system."; + case SaitenStatusMode.Saitening: + return "Saiteining..."; + default: + return "Oops..."; + } + } + + internal class StatusSpriteText : MarkdownTextFlowContainer + { + public StatusSpriteText(string text) + { + var block = Markdig.Markdown.Parse(text).OfType().FirstOrDefault(); + + if (block != null) + AddInlineText(block.Inline); + } } } From 45a26d1110bd7ce25a4eb8a4ecf7c87f03e61108 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 1 Aug 2020 23:19:57 +0900 Subject: [PATCH 3/6] Add saiten status into note platfield. --- .../UI/TestCaseSaitenStatus.cs | 1 + .../UI/Components/SaitenStatus.cs | 20 ++++++++++++------- osu.Game.Rulesets.Karaoke/UI/NotePlayfield.cs | 9 ++++++++- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/UI/TestCaseSaitenStatus.cs b/osu.Game.Rulesets.Karaoke.Tests/UI/TestCaseSaitenStatus.cs index 55940bc8b..00b5174a1 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/UI/TestCaseSaitenStatus.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/UI/TestCaseSaitenStatus.cs @@ -18,6 +18,7 @@ public class TestCaseSaitenStatus : OsuTestScene [TestCase(SaitenStatusMode.OSXMicrophonePermissionDeclined)] [TestCase(SaitenStatusMode.OSXDoesNotSupported)] [TestCase(SaitenStatusMode.WindowsMicrophonePermissionDeclined)] + [TestCase(SaitenStatusMode.NoMicrophoneDevice)] [TestCase(SaitenStatusMode.Saitening)] public void TestMode(SaitenStatusMode mode) { diff --git a/osu.Game.Rulesets.Karaoke/UI/Components/SaitenStatus.cs b/osu.Game.Rulesets.Karaoke/UI/Components/SaitenStatus.cs index 92382eae4..47605531a 100644 --- a/osu.Game.Rulesets.Karaoke/UI/Components/SaitenStatus.cs +++ b/osu.Game.Rulesets.Karaoke/UI/Components/SaitenStatus.cs @@ -88,7 +88,7 @@ public enum SaitenStatusMode /// /// Due to android device does not authorize microphone access. /// - [Description("Android permission declined")] + [Description("Android permission declined.")] AndroidMicrophonePermissionDeclined, /// @@ -96,13 +96,13 @@ public enum SaitenStatusMode /// Will throw this if osu.framework.microphone does not supportu it yet. /// Or official client does not open this permission. /// - [Description("Android target not supported")] + [Description("Android target not supported.")] AndroidDoesNotSupported, /// /// Due to iOS device does not authorize microphone access. /// - [Description("iOS permission declined")] + [Description("iOS permission declined.")] IOSMicrophonePermissionDeclined, /// @@ -110,13 +110,13 @@ public enum SaitenStatusMode /// Will throw this if osu.framework.microphone does not supportu it yet. /// Or official client does not open this permission. /// - [Description("iOS target not supported")] + [Description("iOS target not supported.")] IOSDoesNotSupported, /// /// Due to osx device does not authorize microphone access. /// - [Description("osx permission declined")] + [Description("osx permission declined.")] OSXMicrophonePermissionDeclined, /// @@ -124,7 +124,7 @@ public enum SaitenStatusMode /// Will throw this if osu.framework.microphone does not supportu it yet. /// Or official client does not open this permission. /// - [Description("osx target not supported")] + [Description("osx target not supported.")] OSXDoesNotSupported, /// @@ -132,9 +132,15 @@ public enum SaitenStatusMode /// Windows client don't need to ask permission. /// Open lazer client with admin permission can solve that. /// - [Description("Windows permission declined")] + [Description("Windows permission declined.")] WindowsMicrophonePermissionDeclined, + /// + /// No microphone device in this computer/macbook. + /// + [Description("No microphone device.")] + NoMicrophoneDevice, + /// /// Everything works well. /// diff --git a/osu.Game.Rulesets.Karaoke/UI/NotePlayfield.cs b/osu.Game.Rulesets.Karaoke/UI/NotePlayfield.cs index 826c35336..d3645605c 100644 --- a/osu.Game.Rulesets.Karaoke/UI/NotePlayfield.cs +++ b/osu.Game.Rulesets.Karaoke/UI/NotePlayfield.cs @@ -47,6 +47,8 @@ public class NotePlayfield : ScrollingPlayfield, IKeyBindingHandler Date: Sun, 2 Aug 2020 12:20:26 +0900 Subject: [PATCH 4/6] 1. Add more 4 cases 2. Implemenrt change in gameplay. --- .../UI/TestCaseSaitenStatus.cs | 4 ++ .../Configuration/KaraokeSessionStatics.cs | 7 +++ .../KaraokeInputManager.cs | 35 +++++++++--- .../Mods/KaraokeModDisableNote.cs | 4 +- .../UI/Components/SaitenStatus.cs | 54 +++++++++++++++++-- osu.Game.Rulesets.Karaoke/UI/NotePlayfield.cs | 7 ++- 6 files changed, 96 insertions(+), 15 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/UI/TestCaseSaitenStatus.cs b/osu.Game.Rulesets.Karaoke.Tests/UI/TestCaseSaitenStatus.cs index 00b5174a1..28d3a1750 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/UI/TestCaseSaitenStatus.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/UI/TestCaseSaitenStatus.cs @@ -19,7 +19,11 @@ public class TestCaseSaitenStatus : OsuTestScene [TestCase(SaitenStatusMode.OSXDoesNotSupported)] [TestCase(SaitenStatusMode.WindowsMicrophonePermissionDeclined)] [TestCase(SaitenStatusMode.NoMicrophoneDevice)] + [TestCase(SaitenStatusMode.NotSaitening)] + [TestCase(SaitenStatusMode.AutoPlay)] + [TestCase(SaitenStatusMode.Edit)] [TestCase(SaitenStatusMode.Saitening)] + [TestCase(SaitenStatusMode.NotInitialized)] public void TestMode(SaitenStatusMode mode) { AddStep("create mod display", () => diff --git a/osu.Game.Rulesets.Karaoke/Configuration/KaraokeSessionStatics.cs b/osu.Game.Rulesets.Karaoke/Configuration/KaraokeSessionStatics.cs index 83c9e0648..8264105f2 100644 --- a/osu.Game.Rulesets.Karaoke/Configuration/KaraokeSessionStatics.cs +++ b/osu.Game.Rulesets.Karaoke/Configuration/KaraokeSessionStatics.cs @@ -6,6 +6,7 @@ using osu.Game.Configuration; using osu.Game.Rulesets.Karaoke.Beatmaps; using osu.Game.Rulesets.Karaoke.Objects; +using osu.Game.Rulesets.Karaoke.UI.Components; namespace osu.Game.Rulesets.Karaoke.Configuration { @@ -50,6 +51,9 @@ public KaraokeSessionStatics(KaraokeRulesetConfigManager config, IBeatmap beatma // Practice Set(KaraokeRulesetSession.NowLyric, null); + + // Saiten stsus + Set(KaraokeRulesetSession.SaitenStatus, SaitenStatusMode.NotInitialized); } private T getValue(KaraokeRulesetSetting setting) => rulesetConfigManager.GetBindable(setting).Value; @@ -75,5 +79,8 @@ public enum KaraokeRulesetSession // Practice NowLyric, + + // Saiten status + SaitenStatus, } } diff --git a/osu.Game.Rulesets.Karaoke/KaraokeInputManager.cs b/osu.Game.Rulesets.Karaoke/KaraokeInputManager.cs index 42ed0428c..a0d67dde8 100644 --- a/osu.Game.Rulesets.Karaoke/KaraokeInputManager.cs +++ b/osu.Game.Rulesets.Karaoke/KaraokeInputManager.cs @@ -12,11 +12,13 @@ using osu.Framework.Input.Handlers.Microphone; using osu.Framework.Input.StateChanges.Events; using osu.Framework.Input.States; +using osu.Framework.Logging; using osu.Game.Beatmaps; using osu.Game.Input.Handlers; using osu.Game.Rulesets.Karaoke.Beatmaps; using osu.Game.Rulesets.Karaoke.Configuration; using osu.Game.Rulesets.Karaoke.Mods; +using osu.Game.Rulesets.Karaoke.UI.Components; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.UI; using osu.Game.Screens.Edit; @@ -34,27 +36,48 @@ public KaraokeInputManager(RulesetInfo ruleset) private IBeatmap beatmap; [BackgroundDependencyLoader(true)] - private void load(KaraokeRulesetConfigManager config, IBindable> mods, IBindable beatmap, EditorBeatmap editorBeatmap) + private void load(KaraokeRulesetConfigManager config, IBindable> mods, IBindable beatmap, KaraokeSessionStatics session, EditorBeatmap editorBeatmap) { if (editorBeatmap != null) + { + session.Set(KaraokeRulesetSession.SaitenStatus, SaitenStatusMode.Edit); return; + } this.beatmap = beatmap.Value.Beatmap; var disableMicrophoneDeviceByMod = mods.Value.OfType().Any(x => !x.MicrophoneEnabled); if (disableMicrophoneDeviceByMod) + { + session.Set(KaraokeRulesetSession.SaitenStatus, SaitenStatusMode.AutoPlay); return; + } + var beatmapSaitenable = beatmap.Value.Beatmap.IsScorable(); if (!beatmapSaitenable) + { + session.Set(KaraokeRulesetSession.SaitenStatus, SaitenStatusMode.NotSaitening); return; + } - var selectedDevice = config.GetBindable(KaraokeRulesetSetting.MicrophoneDevice).Value; - var microphoneList = new MicrophoneManager().MicrophoneDeviceNames.ToList(); + try + { + var selectedDevice = config.GetBindable(KaraokeRulesetSetting.MicrophoneDevice).Value; + var microphoneList = new MicrophoneManager().MicrophoneDeviceNames.ToList(); + + // Find index by selection id + var deviceIndex = microphoneList.IndexOf(selectedDevice); + AddHandler(new OsuTKMicrophoneHandler(deviceIndex)); - // Find index by selection id - var deviceIndex = microphoneList.IndexOf(selectedDevice); - AddHandler(new OsuTKMicrophoneHandler(deviceIndex)); + session.Set(KaraokeRulesetSession.SaitenStatus, SaitenStatusMode.Saitening); + } + catch(Exception ex) + { + Logger.Error(ex, "Microphone initialize error."); + // todo : set real error by exception + session.Set(KaraokeRulesetSession.SaitenStatus, SaitenStatusMode.WindowsMicrophonePermissionDeclined); + } } protected override InputState CreateInitialState() diff --git a/osu.Game.Rulesets.Karaoke/Mods/KaraokeModDisableNote.cs b/osu.Game.Rulesets.Karaoke/Mods/KaraokeModDisableNote.cs index a1c02dbf0..aae74dce0 100644 --- a/osu.Game.Rulesets.Karaoke/Mods/KaraokeModDisableNote.cs +++ b/osu.Game.Rulesets.Karaoke/Mods/KaraokeModDisableNote.cs @@ -9,7 +9,7 @@ namespace osu.Game.Rulesets.Karaoke.Mods { - public class KaraokeModDisableNote : Mod, IApplicableToHitObject, IApplicableToMicrophone + public class KaraokeModDisableNote : Mod, IApplicableToHitObject { public override string Name => "Disable note"; public override string Acronym => "DN"; @@ -17,8 +17,6 @@ public class KaraokeModDisableNote : Mod, IApplicableToHitObject, IApplicableToM public override IconUsage? Icon => KaraokeIcon.ModDisableNote; public override ModType Type => ModType.Fun; - public bool MicrophoneEnabled => false; - public void ApplyToHitObject(HitObject hitObject) { if (hitObject is Note note) diff --git a/osu.Game.Rulesets.Karaoke/UI/Components/SaitenStatus.cs b/osu.Game.Rulesets.Karaoke/UI/Components/SaitenStatus.cs index 47605531a..dca433c2e 100644 --- a/osu.Game.Rulesets.Karaoke/UI/Components/SaitenStatus.cs +++ b/osu.Game.Rulesets.Karaoke/UI/Components/SaitenStatus.cs @@ -39,11 +39,23 @@ public SaitenStatus(SaitenStatusMode statusMode) Spacing = new Vector2(5); Direction = FillDirection.Horizontal; AutoSizeAxes = Axes.Both; - Children = new Drawable[] + SaitenStatusMode = statusMode; + } + + private SaitenStatusMode statusMode; + + public SaitenStatusMode SaitenStatusMode + { + get => statusMode; + set { - CreateIcon(statusMode == SaitenStatusMode.Saitening), - CreateStatusSpriteText(GetSaitenStatusText(statusMode)) - }; + statusMode = value; + Children = new Drawable[] + { + CreateIcon(statusMode == SaitenStatusMode.Saitening), + CreateStatusSpriteText(GetSaitenStatusText(statusMode)) + }; + } } protected virtual string GetSaitenStatusText(SaitenStatusMode statusMode) @@ -64,10 +76,18 @@ protected virtual string GetSaitenStatusText(SaitenStatusMode statusMode) return "Osx device haven't support saiten system yet :("; case SaitenStatusMode.WindowsMicrophonePermissionDeclined: return "Open lazer with admin permission to enable saiten system."; + case SaitenStatusMode.NotSaitening: + return "This beatmap is not saitenable."; + case SaitenStatusMode.AutoPlay: + return "Auto play mode."; + case SaitenStatusMode.Edit: + return "Edit mode."; case SaitenStatusMode.Saitening: return "Saiteining..."; + case SaitenStatusMode.NotInitialized: + return "Weird... Should not goes to here :thinking:"; default: - return "Oops..."; + return "Weird... Should not goes to here either :oops:"; } } @@ -141,10 +161,34 @@ public enum SaitenStatusMode [Description("No microphone device.")] NoMicrophoneDevice, + /// + /// Beatmap is not scoring. + /// + [Description("No saitening.")] + NotSaitening, + + /// + /// Beatmap is not scoring. + /// + [Description("Autoplay.")] + AutoPlay, + + /// + /// In edit mode. + /// + [Description("Edit mode.")] + Edit, + /// /// Everything works well. /// [Description("Saitening...")] Saitening, + + /// + /// Microphone statis is not initialized. + /// + [Description("Not initialized.")] + NotInitialized, } } diff --git a/osu.Game.Rulesets.Karaoke/UI/NotePlayfield.cs b/osu.Game.Rulesets.Karaoke/UI/NotePlayfield.cs index d3645605c..6e455914a 100644 --- a/osu.Game.Rulesets.Karaoke/UI/NotePlayfield.cs +++ b/osu.Game.Rulesets.Karaoke/UI/NotePlayfield.cs @@ -170,7 +170,7 @@ public NotePlayfield(int columns) }, } }, - new SaitenStatus(SaitenStatusMode.Saitening) + saitenStatus = new SaitenStatus(SaitenStatusMode.NotInitialized) { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, @@ -305,6 +305,11 @@ private void load(OsuColour colours, KaraokeSessionStatics session) realTimeSaitenVisualization.LineColour = colours.Yellow; session.BindWith(KaraokeRulesetSession.SaitenPitch, saitenPitch); + + session.GetBindable(KaraokeRulesetSession.SaitenStatus).BindValueChanged(e => + { + saitenStatus.SaitenStatusMode = e.NewValue; + }); } public bool OnPressed(KaraokeSaitenAction action) From 80ca68d8c87afc1cdcc731676d2f4f1c0f62a424 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 2 Aug 2020 12:20:42 +0900 Subject: [PATCH 5/6] Fix test case and change text. --- .../Skinning/KaraokeSkinnableColumnTestScene.cs | 5 ++++- .../Skinning/TestSceneNotePlayfield.cs | 3 --- osu.Game.Rulesets.Karaoke/UI/Components/SaitenStatus.cs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/Skinning/KaraokeSkinnableColumnTestScene.cs b/osu.Game.Rulesets.Karaoke.Tests/Skinning/KaraokeSkinnableColumnTestScene.cs index 65962d892..dbed4779c 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Skinning/KaraokeSkinnableColumnTestScene.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Skinning/KaraokeSkinnableColumnTestScene.cs @@ -48,9 +48,12 @@ protected KaraokeSkinnableColumnTestScene() [BackgroundDependencyLoader] private void load(RulesetConfigCache configCache) { - // Cache ruleset config manager because karaoke input manager need it. + // Cache ruleset config manager and session because karaoke input manager need it. var config = (KaraokeRulesetConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance()); + var session = new KaraokeSessionStatics(config, null); + Dependencies.Cache(config); + Dependencies.Cache(session); } [Test] diff --git a/osu.Game.Rulesets.Karaoke.Tests/Skinning/TestSceneNotePlayfield.cs b/osu.Game.Rulesets.Karaoke.Tests/Skinning/TestSceneNotePlayfield.cs index 4c9fd16cc..dda8221ab 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Skinning/TestSceneNotePlayfield.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Skinning/TestSceneNotePlayfield.cs @@ -12,9 +12,6 @@ public class TestSceneNotePlayfield : KaraokeSkinnableColumnTestScene [BackgroundDependencyLoader] private void load(RulesetConfigCache configCache) { - var config = (KaraokeRulesetConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance()); - Dependencies.Cache(new KaraokeSessionStatics(config, null)); - SetContents(() => new KaraokeInputManager(new KaraokeRuleset().RulesetInfo) { Child = new NotePlayfield(COLUMN_NUMBER) diff --git a/osu.Game.Rulesets.Karaoke/UI/Components/SaitenStatus.cs b/osu.Game.Rulesets.Karaoke/UI/Components/SaitenStatus.cs index dca433c2e..fa97897fc 100644 --- a/osu.Game.Rulesets.Karaoke/UI/Components/SaitenStatus.cs +++ b/osu.Game.Rulesets.Karaoke/UI/Components/SaitenStatus.cs @@ -85,7 +85,7 @@ protected virtual string GetSaitenStatusText(SaitenStatusMode statusMode) case SaitenStatusMode.Saitening: return "Saiteining..."; case SaitenStatusMode.NotInitialized: - return "Weird... Should not goes to here :thinking:"; + return "Seems microphone device is not ready."; default: return "Weird... Should not goes to here either :oops:"; } From 577ce6153f911a3031ed2ed07592c7e91294247f Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sun, 2 Aug 2020 12:28:43 +0900 Subject: [PATCH 6/6] Clean-up code by rider <3 Also update nuget package. --- .../Skinning/TestSceneNotePlayfield.cs | 1 - osu.Game.Rulesets.Karaoke/KaraokeInputManager.cs | 7 ++++--- osu.Game.Rulesets.Karaoke/KaraokeRuleset.cs | 1 - .../Changelog/ChangeLogMarkdownContainer.cs | 7 +++++-- .../Skinning/KaraokeInternalSkin.cs | 2 +- .../Skinning/KaraokeLegacySkinTransformer.cs | 3 --- .../UI/Components/SaitenStatus.cs | 14 +++++++++++++- .../osu.Game.Rulesets.Karaoke.csproj | 2 +- 8 files changed, 24 insertions(+), 13 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/Skinning/TestSceneNotePlayfield.cs b/osu.Game.Rulesets.Karaoke.Tests/Skinning/TestSceneNotePlayfield.cs index dda8221ab..e2546c4ab 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Skinning/TestSceneNotePlayfield.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Skinning/TestSceneNotePlayfield.cs @@ -2,7 +2,6 @@ // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; -using osu.Game.Rulesets.Karaoke.Configuration; using osu.Game.Rulesets.Karaoke.UI; namespace osu.Game.Rulesets.Karaoke.Tests.Skinning diff --git a/osu.Game.Rulesets.Karaoke/KaraokeInputManager.cs b/osu.Game.Rulesets.Karaoke/KaraokeInputManager.cs index a0d67dde8..b04a68c7e 100644 --- a/osu.Game.Rulesets.Karaoke/KaraokeInputManager.cs +++ b/osu.Game.Rulesets.Karaoke/KaraokeInputManager.cs @@ -42,19 +42,20 @@ private void load(KaraokeRulesetConfigManager config, IBindable().Any(x => !x.MicrophoneEnabled); + if (disableMicrophoneDeviceByMod) { session.Set(KaraokeRulesetSession.SaitenStatus, SaitenStatusMode.AutoPlay); return; } - var beatmapSaitenable = beatmap.Value.Beatmap.IsScorable(); + if (!beatmapSaitenable) { session.Set(KaraokeRulesetSession.SaitenStatus, SaitenStatusMode.NotSaitening); @@ -72,7 +73,7 @@ private void load(KaraokeRulesetConfigManager config, IBindable githubUrls = new Dictionary + private readonly IDictionary githubUrls = new Dictionary { { "karaoke", "https://github.com/karaoke-dev/karaoke/" }, { "edge", "https://github.com/karaoke-dev/karaoke" }, @@ -193,13 +193,14 @@ protected override void AddLinkText(string text, LinkInline linkInline) var baseUri = new Uri(githubUrls[text]); // Get hash tag with number - var pattern = @"(\#[0-9]+\b)(?!;)"; + const string pattern = @"(\#[0-9]+\b)(?!;)"; var issueOrRequests = Regex.Matches(linkInline.Url, pattern, RegexOptions.IgnoreCase); if (!issueOrRequests.Any()) return; AddText("("); + foreach (var issue in issueOrRequests.Select(x=>x.Value)) { AddDrawable(new MarkdownLinkText($"{text}{issue}", new LinkInline @@ -210,10 +211,12 @@ protected override void AddLinkText(string text, LinkInline linkInline) if(issue != issueOrRequests.LastOrDefault()?.Value) AddText(", "); } + AddText(")"); // add use name if has user var user = linkInline.Url.Split('@').LastOrDefault(); + if (!string.IsNullOrEmpty(user)) { var textScale = new Vector2(0.7f); diff --git a/osu.Game.Rulesets.Karaoke/Skinning/KaraokeInternalSkin.cs b/osu.Game.Rulesets.Karaoke/Skinning/KaraokeInternalSkin.cs index 72d78200a..fbbc2962e 100644 --- a/osu.Game.Rulesets.Karaoke/Skinning/KaraokeInternalSkin.cs +++ b/osu.Game.Rulesets.Karaoke/Skinning/KaraokeInternalSkin.cs @@ -27,7 +27,7 @@ public abstract class KaraokeInternalSkin : ISkin protected abstract string ResourceName { get; } - public KaraokeInternalSkin() + protected KaraokeInternalSkin() { // TODO : need a better way to load resource var assembly = Assembly.GetExecutingAssembly(); diff --git a/osu.Game.Rulesets.Karaoke/Skinning/KaraokeLegacySkinTransformer.cs b/osu.Game.Rulesets.Karaoke/Skinning/KaraokeLegacySkinTransformer.cs index e6c93c1ad..3bfee7bda 100644 --- a/osu.Game.Rulesets.Karaoke/Skinning/KaraokeLegacySkinTransformer.cs +++ b/osu.Game.Rulesets.Karaoke/Skinning/KaraokeLegacySkinTransformer.cs @@ -5,11 +5,8 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; -using osu.Framework.Audio.Sample; using osu.Framework.Bindables; using osu.Framework.Graphics; -using osu.Framework.Graphics.Textures; -using osu.Game.Audio; using osu.Game.IO; using osu.Game.Rulesets.Karaoke.Beatmaps.Formats; using osu.Game.Rulesets.Karaoke.Skinning.Components; diff --git a/osu.Game.Rulesets.Karaoke/UI/Components/SaitenStatus.cs b/osu.Game.Rulesets.Karaoke/UI/Components/SaitenStatus.cs index fa97897fc..544b5a271 100644 --- a/osu.Game.Rulesets.Karaoke/UI/Components/SaitenStatus.cs +++ b/osu.Game.Rulesets.Karaoke/UI/Components/SaitenStatus.cs @@ -50,7 +50,7 @@ public SaitenStatusMode SaitenStatusMode set { statusMode = value; - Children = new Drawable[] + Children = new[] { CreateIcon(statusMode == SaitenStatusMode.Saitening), CreateStatusSpriteText(GetSaitenStatusText(statusMode)) @@ -64,28 +64,40 @@ protected virtual string GetSaitenStatusText(SaitenStatusMode statusMode) { case SaitenStatusMode.AndroidMicrophonePermissionDeclined: return "Go to setting to open permission for lazer."; + case SaitenStatusMode.AndroidDoesNotSupported: return "Android device haven't support saiten system yet :("; + case SaitenStatusMode.IOSMicrophonePermissionDeclined: return "Go to setting to open permission for lazer."; + case SaitenStatusMode.IOSDoesNotSupported: return "iOS device haven't support saiten system yet :("; + case SaitenStatusMode.OSXMicrophonePermissionDeclined: return "Go to setting to open permission for lazer."; + case SaitenStatusMode.OSXDoesNotSupported: return "Osx device haven't support saiten system yet :("; + case SaitenStatusMode.WindowsMicrophonePermissionDeclined: return "Open lazer with admin permission to enable saiten system."; + case SaitenStatusMode.NotSaitening: return "This beatmap is not saitenable."; + case SaitenStatusMode.AutoPlay: return "Auto play mode."; + case SaitenStatusMode.Edit: return "Edit mode."; + case SaitenStatusMode.Saitening: return "Saiteining..."; + case SaitenStatusMode.NotInitialized: return "Seems microphone device is not ready."; + default: return "Weird... Should not goes to here either :oops:"; } diff --git a/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj b/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj index 1a68a9246..d2f64ea3c 100644 --- a/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj +++ b/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj @@ -13,7 +13,7 @@ - +