From 0dc7c3a414abccfba3f8202939b20e957a4dfe3d Mon Sep 17 00:00:00 2001 From: andy840119 Date: Tue, 28 Jun 2022 20:09:07 +0800 Subject: [PATCH 1/5] Remove the nullable disable flag in the change handler mode state. --- .../Edit/Lyrics/States/Modes/EditNoteModeState.cs | 2 -- .../Edit/Lyrics/States/Modes/EditRomajiModeState.cs | 2 -- .../Edit/Lyrics/States/Modes/EditRubyModeState.cs | 2 -- .../Edit/Lyrics/States/Modes/IEditNoteModeState.cs | 2 -- .../Edit/Lyrics/States/Modes/IEditRomajiModeState.cs | 2 -- .../Edit/Lyrics/States/Modes/IEditRubyModeState.cs | 2 -- .../Edit/Lyrics/States/Modes/IHasBlueprintSelection.cs | 2 -- .../Edit/Lyrics/States/Modes/IHasEditModeState.cs | 2 -- .../Edit/Lyrics/States/Modes/IHasSpecialAction.cs | 2 -- .../Edit/Lyrics/States/Modes/ILanguageModeState.cs | 2 -- .../Edit/Lyrics/States/Modes/IManageModeState.cs | 2 -- .../Edit/Lyrics/States/Modes/ITimeTagModeState.cs | 2 -- .../Edit/Lyrics/States/Modes/LanguageEditMode.cs | 2 -- .../Edit/Lyrics/States/Modes/LanguageModeState.cs | 2 -- .../Edit/Lyrics/States/Modes/ManageModeState.cs | 2 -- .../Edit/Lyrics/States/Modes/NoteEditMode.cs | 2 -- .../Edit/Lyrics/States/Modes/TextTagEditMode.cs | 2 -- .../Edit/Lyrics/States/Modes/TimeTagEditMode.cs | 2 -- .../Edit/Lyrics/States/Modes/TimeTagModeState.cs | 2 -- 19 files changed, 38 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditNoteModeState.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditNoteModeState.cs index 8427049cf..a22ecc379 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditNoteModeState.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditNoteModeState.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditRomajiModeState.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditRomajiModeState.cs index 1f637dce2..9edf45583 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditRomajiModeState.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditRomajiModeState.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Rulesets.Karaoke.Objects; diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditRubyModeState.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditRubyModeState.cs index 813c2db96..2764e1865 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditRubyModeState.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/EditRubyModeState.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Rulesets.Karaoke.Objects; diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/IEditNoteModeState.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/IEditNoteModeState.cs index aef4d30e1..5264bbb62 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/IEditNoteModeState.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/IEditNoteModeState.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using osu.Framework.Bindables; using osu.Game.Rulesets.Karaoke.Edit.Lyrics.Extends.Notes; using osu.Game.Rulesets.Karaoke.Objects; diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/IEditRomajiModeState.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/IEditRomajiModeState.cs index d5f965b05..e78b3a476 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/IEditRomajiModeState.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/IEditRomajiModeState.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using osu.Game.Rulesets.Karaoke.Objects; namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.States.Modes diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/IEditRubyModeState.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/IEditRubyModeState.cs index 4bd2f4d86..d1bb96622 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/IEditRubyModeState.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/IEditRubyModeState.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using osu.Game.Rulesets.Karaoke.Objects; namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.States.Modes diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/IHasBlueprintSelection.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/IHasBlueprintSelection.cs index fea907017..e5fc968dc 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/IHasBlueprintSelection.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/IHasBlueprintSelection.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using osu.Framework.Bindables; namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.States.Modes diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/IHasEditModeState.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/IHasEditModeState.cs index 0d5c8e70f..2e791031e 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/IHasEditModeState.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/IHasEditModeState.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using osu.Framework.Bindables; diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/IHasSpecialAction.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/IHasSpecialAction.cs index 421f3e5f3..6ce4225ab 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/IHasSpecialAction.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/IHasSpecialAction.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using osu.Framework.Bindables; diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/ILanguageModeState.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/ILanguageModeState.cs index e1282c9c8..dd2857dfa 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/ILanguageModeState.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/ILanguageModeState.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using osu.Game.Rulesets.Karaoke.Edit.Lyrics.Extends.Languages; namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.States.Modes diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/IManageModeState.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/IManageModeState.cs index b83aeede4..e47d84ca6 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/IManageModeState.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/IManageModeState.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using osu.Game.Rulesets.Karaoke.Edit.Lyrics.Extends.Manage; namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.States.Modes diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/ITimeTagModeState.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/ITimeTagModeState.cs index e32f4c316..33f35c244 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/ITimeTagModeState.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/ITimeTagModeState.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using osu.Framework.Bindables; using osu.Game.Rulesets.Karaoke.Objects; diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/LanguageEditMode.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/LanguageEditMode.cs index 1f459a492..f04a12e0f 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/LanguageEditMode.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/LanguageEditMode.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.States.Modes { public enum LanguageEditMode diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/LanguageModeState.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/LanguageModeState.cs index 8bcffe646..62889ae78 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/LanguageModeState.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/LanguageModeState.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Rulesets.Karaoke.Edit.Lyrics.Extends.Languages; diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/ManageModeState.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/ManageModeState.cs index 7106fb4b0..433c37e20 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/ManageModeState.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/ManageModeState.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Game.Rulesets.Karaoke.Edit.Lyrics.Extends.Manage; diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/NoteEditMode.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/NoteEditMode.cs index 69772f83b..ba9b34f22 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/NoteEditMode.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/NoteEditMode.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.States.Modes { public enum NoteEditMode diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/TextTagEditMode.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/TextTagEditMode.cs index d8140370c..729792711 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/TextTagEditMode.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/TextTagEditMode.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.States.Modes { public enum TextTagEditMode diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/TimeTagEditMode.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/TimeTagEditMode.cs index 96add785c..f2bacfdba 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/TimeTagEditMode.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/TimeTagEditMode.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.States.Modes { public enum TimeTagEditMode diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/TimeTagModeState.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/TimeTagModeState.cs index 0d1a60b5e..702daa9a6 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/TimeTagModeState.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/Modes/TimeTagModeState.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; From e370d6f1e595800159c1820350fc3061c9281737 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Tue, 28 Jun 2022 20:09:46 +0800 Subject: [PATCH 2/5] Remove the remaining nullable disable flag in the change handler state. --- .../Edit/Lyrics/States/CreateTimeTagEditMode.cs | 2 -- .../Edit/Lyrics/States/ILyricCaretState.cs | 2 -- .../Edit/Lyrics/States/ILyricSelectionState.cs | 2 -- osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/LyricCaretState.cs | 2 -- .../Edit/Lyrics/States/LyricEditorSelectingAction.cs | 2 -- .../Edit/Lyrics/States/LyricSelectionState.cs | 2 -- .../Edit/Lyrics/States/MovingCaretAction.cs | 2 -- 7 files changed, 14 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/CreateTimeTagEditMode.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/CreateTimeTagEditMode.cs index 8b89bd980..a13f1d799 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/CreateTimeTagEditMode.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/CreateTimeTagEditMode.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.States { public enum CreateTimeTagEditMode diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/ILyricCaretState.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/ILyricCaretState.cs index 749d4a391..f49e0d122 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/ILyricCaretState.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/ILyricCaretState.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using osu.Framework.Bindables; using osu.Game.Rulesets.Karaoke.Edit.Lyrics.CaretPosition; using osu.Game.Rulesets.Karaoke.Edit.Lyrics.CaretPosition.Algorithms; diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/ILyricSelectionState.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/ILyricSelectionState.cs index da2f37a02..51fd60bb4 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/ILyricSelectionState.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/ILyricSelectionState.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using System.Collections.Generic; using osu.Framework.Bindables; diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/LyricCaretState.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/LyricCaretState.cs index 61bfb7ef4..b092018dd 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/LyricCaretState.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/LyricCaretState.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using System.ComponentModel; using System.Linq; diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/LyricEditorSelectingAction.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/LyricEditorSelectingAction.cs index 6f91e304e..5eaff22e7 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/LyricEditorSelectingAction.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/LyricEditorSelectingAction.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.States { public enum LyricEditorSelectingAction diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/LyricSelectionState.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/LyricSelectionState.cs index 8766c5281..38a70a537 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/LyricSelectionState.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/LyricSelectionState.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using System.Collections.Generic; using System.Linq; diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/MovingCaretAction.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/MovingCaretAction.cs index c316467a8..c4b3200b3 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/MovingCaretAction.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/MovingCaretAction.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.States { public enum MovingCaretAction From a1c12c62e20f3c0ad8696fa52c410cb9a8d49bfb Mon Sep 17 00:00:00 2001 From: andy840119 Date: Tue, 28 Jun 2022 20:28:27 +0800 Subject: [PATCH 3/5] Fix the api broken. --- .../Edit/Lyrics/States/ILyricCaretState.cs | 6 +-- .../Lyrics/States/ILyricSelectionState.cs | 2 +- .../Edit/Lyrics/States/LyricCaretState.cs | 40 +++++++++---------- .../Edit/Lyrics/States/LyricSelectionState.cs | 10 ++--- 4 files changed, 27 insertions(+), 31 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/ILyricCaretState.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/ILyricCaretState.cs index f49e0d122..61f9c5beb 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/ILyricCaretState.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/ILyricCaretState.cs @@ -10,11 +10,11 @@ namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.States { public interface ILyricCaretState { - IBindable BindableHoverCaretPosition { get; } + IBindable BindableHoverCaretPosition { get; } - IBindable BindableCaretPosition { get; } + IBindable BindableCaretPosition { get; } - IBindable BindableCaretPositionAlgorithm { get; } + IBindable BindableCaretPositionAlgorithm { get; } bool MoveCaret(MovingCaretAction action); diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/ILyricSelectionState.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/ILyricSelectionState.cs index 51fd60bb4..60ec15909 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/ILyricSelectionState.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/ILyricSelectionState.cs @@ -17,7 +17,7 @@ public interface ILyricSelectionState IBindableList SelectedLyrics { get; } - Action Action { get; set; } + Action? Action { get; set; } void StartSelecting(); diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/LyricCaretState.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/LyricCaretState.cs index b092018dd..aa76443f9 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/LyricCaretState.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/LyricCaretState.cs @@ -3,6 +3,7 @@ using System; using System.ComponentModel; +using System.Diagnostics.CodeAnalysis; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; @@ -19,16 +20,16 @@ namespace osu.Game.Rulesets.Karaoke.Edit.Lyrics.States { public class LyricCaretState : Component, ILyricCaretState { - public IBindable BindableHoverCaretPosition => bindableHoverCaretPosition; - public IBindable BindableCaretPosition => bindableCaretPosition; + public IBindable BindableHoverCaretPosition => bindableHoverCaretPosition; + public IBindable BindableCaretPosition => bindableCaretPosition; - public IBindable BindableCaretPositionAlgorithm => bindableCaretPositionAlgorithm; + public IBindable BindableCaretPositionAlgorithm => bindableCaretPositionAlgorithm; - private readonly Bindable bindableHoverCaretPosition = new(); - private readonly Bindable bindableCaretPosition = new(); - private readonly Bindable bindableCaretPositionAlgorithm = new(); + private readonly Bindable bindableHoverCaretPosition = new(); + private readonly Bindable bindableCaretPosition = new(); + private readonly Bindable bindableCaretPositionAlgorithm = new(); - private ICaretPositionAlgorithm algorithm => bindableCaretPositionAlgorithm.Value; + private ICaretPositionAlgorithm? algorithm => bindableCaretPositionAlgorithm.Value; private readonly IBindableList bindableLyrics = new BindableList(); @@ -42,7 +43,7 @@ public class LyricCaretState : Component, ILyricCaretState private readonly IBindable bindableRecordingMovingCaretMode = new Bindable(); private readonly IBindable bindableRecordingChangeTimeWhileMovingTheCaret = new Bindable(); - [Resolved] + [Resolved, AllowNull] private EditorClock editorClock { get; set; } public LyricCaretState() @@ -107,7 +108,7 @@ private void refreshAlgorithmAndCaretPosition() // should update selection if selected lyric changed. postProcess(); - static ICaretPosition getCaretPosition(ICaretPositionAlgorithm algorithm, Lyric lyric) + static ICaretPosition? getCaretPosition(ICaretPositionAlgorithm? algorithm, Lyric? lyric) { if (algorithm == null) return null; @@ -119,7 +120,7 @@ static ICaretPosition getCaretPosition(ICaretPositionAlgorithm algorithm, Lyric } } - private ICaretPositionAlgorithm getAlgorithmByMode() + private ICaretPositionAlgorithm? getAlgorithmByMode() { var lyrics = bindableLyrics.ToArray(); var lyricEditorMode = bindableMode.Value; @@ -185,10 +186,10 @@ public bool MoveCaret(MovingCaretAction action) var position = action switch { - MovingCaretAction.Up => algorithm.MoveUp(currentPosition), - MovingCaretAction.Down => algorithm.MoveDown(currentPosition), - MovingCaretAction.Left => algorithm.MoveLeft(currentPosition), - MovingCaretAction.Right => algorithm.MoveRight(currentPosition), + MovingCaretAction.Up => moveIfNotNull(currentPosition, algorithm.MoveUp), + MovingCaretAction.Down => moveIfNotNull(currentPosition, algorithm.MoveDown), + MovingCaretAction.Left => moveIfNotNull(currentPosition, algorithm.MoveLeft), + MovingCaretAction.Right => moveIfNotNull(currentPosition, algorithm.MoveRight), MovingCaretAction.First => algorithm.MoveToFirst(), MovingCaretAction.Last => algorithm.MoveToLast(), _ => throw new InvalidEnumArgumentException(nameof(action)) @@ -199,6 +200,9 @@ public bool MoveCaret(MovingCaretAction action) MoveCaretToTargetPosition(position); return true; + + static ICaretPosition? moveIfNotNull(ICaretPosition? caretPosition, Func action) + => caretPosition != null ? action.Invoke(caretPosition) : caretPosition; } public void MoveCaretToTargetPosition(Lyric lyric) @@ -218,9 +222,6 @@ public void MoveCaretToTargetPosition(ICaretPosition position) if (position == null) throw new ArgumentNullException(nameof(position)); - if (position.Lyric == null) - return; - bool movable = CaretPositionMovable(position); // stop moving the caret if forbidden by algorithm calculation. @@ -238,9 +239,6 @@ public void MoveHoverCaretToTargetPosition(ICaretPosition position) if (position == null) throw new ArgumentNullException(nameof(position)); - if (position.Lyric == null) - return; - if (!CaretPositionMovable(position)) return; @@ -273,7 +271,7 @@ private void postProcess() var caretPosition = bindableCaretPosition.Value; navigateToTimeByCaretPosition(caretPosition); - void navigateToTimeByCaretPosition(ICaretPosition position) + void navigateToTimeByCaretPosition(ICaretPosition? position) { if (position is not TimeTagCaretPosition timeTagCaretPosition) return; diff --git a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/LyricSelectionState.cs b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/LyricSelectionState.cs index 38a70a537..524908673 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/LyricSelectionState.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/Lyrics/States/LyricSelectionState.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Linq; using osu.Framework.Allocation; using osu.Framework.Bindables; @@ -24,12 +25,12 @@ public class LyricSelectionState : Component, ILyricSelectionState public IBindableList SelectedLyrics => bindableSelectedLyrics; - public Action Action { get; set; } + public Action? Action { get; set; } - [Resolved] + [Resolved, AllowNull] private EditorBeatmap beatmap { get; set; } - [Resolved] + [Resolved, AllowNull] private ILyricCaretState lyricCaretState { get; set; } private readonly BindableBool selecting = new(); @@ -117,9 +118,6 @@ public void UpdateDisableLyricList(IDictionary disable bindableDisableSelectingLyric.Clear(); - if (disableLyrics == null) - return; - foreach ((var lyric, LocalisableString reason) in disableLyrics) bindableDisableSelectingLyric.Add(lyric, reason); } From 7fbeae46fb0c97a2cc33ad59fb60959bb1074e08 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Tue, 28 Jun 2022 20:29:13 +0800 Subject: [PATCH 4/5] Remove the disable null flag. --- .../Editor/Lyrics/States/LyricCaretStateTest.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/Editor/Lyrics/States/LyricCaretStateTest.cs b/osu.Game.Rulesets.Karaoke.Tests/Editor/Lyrics/States/LyricCaretStateTest.cs index 1a7a9127f..330257039 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Editor/Lyrics/States/LyricCaretStateTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Editor/Lyrics/States/LyricCaretStateTest.cs @@ -1,8 +1,6 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using System.Collections.Generic; using NUnit.Framework; From ba03509bbc0650487aff1b6da5c77e7df4ba13b6 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Tue, 28 Jun 2022 20:31:36 +0800 Subject: [PATCH 5/5] Fix the api broken in the test case. --- .../Editor/Lyrics/States/LyricCaretStateTest.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/Editor/Lyrics/States/LyricCaretStateTest.cs b/osu.Game.Rulesets.Karaoke.Tests/Editor/Lyrics/States/LyricCaretStateTest.cs index 330257039..8e3bb5a87 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Editor/Lyrics/States/LyricCaretStateTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Editor/Lyrics/States/LyricCaretStateTest.cs @@ -26,8 +26,8 @@ namespace osu.Game.Rulesets.Karaoke.Tests.Editor.Lyrics.States public class LyricCaretStateTest : OsuTestScene { private readonly IBeatmap beatmap; - private ILyricEditorState state; - private LyricCaretState lyricCaretState; + private ILyricEditorState state = null!; + private LyricCaretState lyricCaretState = null!; public LyricCaretStateTest() { @@ -237,11 +237,11 @@ public void MovingHoverCaretByCaretPositionWithEditMode() // because switch to the singer lyric, so current caret position will at the first lyric. assertCaretPosition(Assert.IsInstanceOf); - assertCaretPosition(x => Assert.AreEqual(firstLyric, x.Lyric)); + assertCaretPosition(x => Assert.AreEqual(firstLyric, x?.Lyric)); // yes, should change the position if contains algorithm. assertHoverCaretPosition(Assert.IsInstanceOf); - assertHoverCaretPosition(x => Assert.AreEqual(targetLyric, x.Lyric)); + assertHoverCaretPosition(x => Assert.AreEqual(targetLyric, x?.Lyric)); } [Test] @@ -316,9 +316,9 @@ private void movingHoverCaretByLyric(ICaretPosition caretPosition, bool exceptSu } private Lyric getLyricFromBeatmap(int index) - => beatmap.HitObjects[index] as Lyric; + => (Lyric)beatmap.HitObjects[index]; - private void assertCaretPosition(Action caretPosition) + private void assertCaretPosition(Action caretPosition) { AddStep("Assert caret position", () => { @@ -326,7 +326,7 @@ private void assertCaretPosition(Action caretPosition) }); } - private void assertHoverCaretPosition(Action caretPosition) + private void assertHoverCaretPosition(Action caretPosition) { AddStep("Assert hover caret position", () => {