Skip to content

Commit

Permalink
Merge pull request #1512 from andy840119/fix-import-lyric-broken
Browse files Browse the repository at this point in the history
Fix cannot import the lyric due to missing depenedency
  • Loading branch information
andy840119 authored Aug 14, 2022
2 parents 0762467 + 89a9a80 commit 5d40a80
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 17 deletions.
67 changes: 51 additions & 16 deletions osu.Game.Rulesets.Karaoke/Edit/Lyrics/LyricEditorClipboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<LyricEditorMode> bindableMode = new Bindable<LyricEditorMode>();

Expand Down Expand Up @@ -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;

Expand All @@ -166,14 +169,17 @@ private bool performCut()
return false;

case LyricEditorMode.Language:
languageChangeHandler.SetLanguage(null);
languageChangeHandler?.SetLanguage(null);
return true;

case LyricEditorMode.EditRuby:
var rubies = editRubyModeState.SelectedItems;
if (!rubies.Any())
return false;

if (lyricRubyTagsChangeHandler == null)
throw new NullDependencyException($"Missing {nameof(lyricRubyTagsChangeHandler)}");

lyricRubyTagsChangeHandler.RemoveRange(rubies);
return true;

Expand All @@ -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;

Expand All @@ -190,13 +199,19 @@ private bool performCut()
if (!timeTags.Any())
return false;

if (lyricTimeTagsChangeHandler == null)
throw new NullDependencyException($"Missing {nameof(lyricTimeTagsChangeHandler)}");

lyricTimeTagsChangeHandler.RemoveRange(timeTags);
return true;

case LyricEditorMode.EditNote:
return false;

case LyricEditorMode.Singer:
if (lyricSingerChangeHandler == null)
throw new NullDependencyException($"Missing {nameof(lyricSingerChangeHandler)}");

lyricSingerChangeHandler.Clear();
return true;

Expand Down Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -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;
Expand All @@ -358,7 +391,9 @@ private bool performPaste(Lyric lyric)
}

private IEnumerable<Singer> getMatchedSinges(IEnumerable<int> 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>(T obj)
{
Expand Down
1 change: 0 additions & 1 deletion osu.Game.Rulesets.Karaoke/Skinning/KaraokeSkin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 5d40a80

Please sign in to comment.