diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/LyricEditorClipboard.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/LyricEditorClipboard.cs index 3d20a9108..b2c9fbe4c 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/LyricEditorClipboard.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/LyricEditorClipboard.cs @@ -47,26 +47,26 @@ public class LyricEditorClipboard : Component, ILyricEditorClipboard [Resolved, AllowNull] private ITimeTagModeState timeTagModeState { get; set; } - [Resolved, AllowNull] - private ILyricsChangeHandler lyricsChangeHandler { get; set; } + [Resolved] + private ILyricsChangeHandler? lyricsChangeHandler { get; set; } - [Resolved, AllowNull] - private ILyricLanguageChangeHandler languageChangeHandler { get; set; } + [Resolved] + private ILyricLanguageChangeHandler? languageChangeHandler { get; set; } - [Resolved, AllowNull] - private ILyricRubyTagsChangeHandler lyricRubyTagsChangeHandler { get; set; } + [Resolved] + private ILyricRubyTagsChangeHandler? lyricRubyTagsChangeHandler { get; set; } - [Resolved, AllowNull] - private ILyricRomajiTagsChangeHandler lyricRomajiTagsChangeHandler { get; set; } + [Resolved] + private ILyricRomajiTagsChangeHandler? lyricRomajiTagsChangeHandler { get; set; } - [Resolved, AllowNull] - private ILyricTimeTagsChangeHandler lyricTimeTagsChangeHandler { get; set; } + [Resolved] + private ILyricTimeTagsChangeHandler? lyricTimeTagsChangeHandler { get; set; } - [Resolved, AllowNull] - private ILyricSingerChangeHandler lyricSingerChangeHandler { get; set; } + [Resolved] + private ILyricSingerChangeHandler? lyricSingerChangeHandler { get; set; } - [Resolved, AllowNull] - private ISingersChangeHandler singersChangeHandler { get; set; } + [Resolved] + private ISingersChangeHandler? singersChangeHandler { get; set; } private readonly IBindable bindableMode = new Bindable(); @@ -155,6 +155,9 @@ private bool performCut() return false; case TextingEditMode.Split: + if (lyricsChangeHandler == null) + throw new NullDependencyException($"Missing {nameof(lyricsChangeHandler)}"); + lyricsChangeHandler.Remove(); return true; @@ -166,7 +169,7 @@ private bool performCut() return false; case LyricEditorMode.Language: - languageChangeHandler.SetLanguage(null); + languageChangeHandler?.SetLanguage(null); return true; case LyricEditorMode.EditRuby: @@ -174,6 +177,9 @@ private bool performCut() if (!rubies.Any()) return false; + if (lyricRubyTagsChangeHandler == null) + throw new NullDependencyException($"Missing {nameof(lyricRubyTagsChangeHandler)}"); + lyricRubyTagsChangeHandler.RemoveRange(rubies); return true; @@ -182,6 +188,9 @@ private bool performCut() if (!romajies.Any()) return false; + if (lyricRomajiTagsChangeHandler == null) + throw new NullDependencyException($"Missing {nameof(lyricRomajiTagsChangeHandler)}"); + lyricRomajiTagsChangeHandler.RemoveRange(romajies); return true; @@ -190,6 +199,9 @@ private bool performCut() if (!timeTags.Any()) return false; + if (lyricTimeTagsChangeHandler == null) + throw new NullDependencyException($"Missing {nameof(lyricTimeTagsChangeHandler)}"); + lyricTimeTagsChangeHandler.RemoveRange(timeTags); return true; @@ -197,6 +209,9 @@ private bool performCut() return false; case LyricEditorMode.Singer: + if (lyricSingerChangeHandler == null) + throw new NullDependencyException($"Missing {nameof(lyricSingerChangeHandler)}"); + lyricSingerChangeHandler.Clear(); return true; @@ -298,6 +313,9 @@ private bool performPaste(Lyric lyric) if (pasteLyric == null) return false; + if (lyricsChangeHandler == null) + throw new NullDependencyException($"Missing {nameof(lyricsChangeHandler)}"); + lyricsChangeHandler.AddBelowToSelection(pasteLyric); return true; @@ -313,6 +331,9 @@ private bool performPaste(Lyric lyric) if (pasteLanguage == null) return false; + if (languageChangeHandler == null) + throw new NullDependencyException($"Missing {nameof(languageChangeHandler)}"); + languageChangeHandler.SetLanguage(pasteLanguage); return true; @@ -321,6 +342,9 @@ private bool performPaste(Lyric lyric) if (pasteRubies == null) return false; + if (lyricRubyTagsChangeHandler == null) + throw new NullDependencyException($"Missing {nameof(lyricRubyTagsChangeHandler)}"); + lyricRubyTagsChangeHandler.AddRange(pasteRubies); return true; @@ -329,6 +353,9 @@ private bool performPaste(Lyric lyric) if (pasteRomajies == null) return false; + if (lyricRomajiTagsChangeHandler == null) + throw new NullDependencyException($"Missing {nameof(lyricRomajiTagsChangeHandler)}"); + lyricRomajiTagsChangeHandler.AddRange(pasteRomajies); return true; @@ -337,6 +364,9 @@ private bool performPaste(Lyric lyric) if (pasteTimeTags == null) return false; + if (lyricTimeTagsChangeHandler == null) + throw new NullDependencyException($"Missing {nameof(lyricTimeTagsChangeHandler)}"); + lyricTimeTagsChangeHandler.AddRange(pasteTimeTags); return true; @@ -348,6 +378,9 @@ private bool performPaste(Lyric lyric) if (pasteSingerIds == null) return false; + if (lyricSingerChangeHandler == null) + throw new NullDependencyException($"Missing {nameof(lyricSingerChangeHandler)}"); + var singers = getMatchedSinges(pasteSingerIds); lyricSingerChangeHandler.AddRange(singers); return true; @@ -358,7 +391,9 @@ private bool performPaste(Lyric lyric) } private IEnumerable getMatchedSinges(IEnumerable singerIds) - => singersChangeHandler.Singers.Where(x => singerIds.Contains(x.ID)); + { + return singersChangeHandler == null ? throw new NullDependencyException($"Missing {nameof(singersChangeHandler)}") : singersChangeHandler.Singers.Where(x => singerIds.Contains(x.ID)); + } private void copyObjectToClipboard(T obj) { diff --git a/osu.Game.Rulesets.Karaoke/Skinning/KaraokeSkin.cs b/osu.Game.Rulesets.Karaoke/Skinning/KaraokeSkin.cs index 77e24a5cf..ad831af58 100644 --- a/osu.Game.Rulesets.Karaoke/Skinning/KaraokeSkin.cs +++ b/osu.Game.Rulesets.Karaoke/Skinning/KaraokeSkin.cs @@ -9,7 +9,6 @@ using Newtonsoft.Json; using osu.Framework.Audio.Sample; using osu.Framework.Bindables; -using osu.Framework.Graphics.OpenGL.Textures; using osu.Framework.Graphics.Textures; using osu.Framework.IO.Stores; using osu.Framework.Logging;