From 497625f0831bdfae5f83ebbb055af959ac697513 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Tue, 25 Jun 2024 23:04:24 +0800 Subject: [PATCH 1/6] Fix the wrong condition check. --- .../Screens/Edit/Beatmaps/Lyrics/LyricEditorVerifier.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/LyricEditorVerifier.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/LyricEditorVerifier.cs index 7b1c81c6b..28c673b89 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/LyricEditorVerifier.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/LyricEditorVerifier.cs @@ -184,7 +184,7 @@ protected override void Dispose(bool isDisposing) base.Dispose(isDisposing); // todo: not very sure - if (!editorBeatmap.IsNull()) + if (editorBeatmap.IsNull()) return; editorBeatmap.HitObjectAdded -= hitObjectAdded; From ed211283002a00f2c7f7e05d779adc7e4f14af82 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Tue, 25 Jun 2024 22:02:50 +0800 Subject: [PATCH 2/6] Re-write the drawable judgement. See: https://github.com/ppy/osu/pull/11167/files --- .../Skinning/TestSceneDrawableJudgement.cs | 3 +- .../UI/DrawableNoteJudgement.cs | 54 +++++++++---------- 2 files changed, 26 insertions(+), 31 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/Skinning/TestSceneDrawableJudgement.cs b/osu.Game.Rulesets.Karaoke.Tests/Skinning/TestSceneDrawableJudgement.cs index 542b45f30..bac4ff048 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Skinning/TestSceneDrawableJudgement.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Skinning/TestSceneDrawableJudgement.cs @@ -6,6 +6,7 @@ using osu.Framework.Extensions; using osu.Framework.Graphics; using osu.Game.Rulesets.Judgements; +using osu.Game.Rulesets.Karaoke.Objects.Drawables; using osu.Game.Rulesets.Karaoke.UI; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Scoring; @@ -19,7 +20,7 @@ public TestSceneDrawableJudgement() foreach (var result in Enum.GetValues().Skip(1)) { AddStep("Show " + result.GetDescription(), () => SetContents(_ => - new DrawableNoteJudgement(new JudgementResult(new HitObject(), new Judgement()) { Type = result }, null) + new DrawableNoteJudgement(new JudgementResult(new HitObject(), new Judgement()) { Type = result }, new DrawableNote()) { Anchor = Anchor.Centre, Origin = Anchor.Centre, diff --git a/osu.Game.Rulesets.Karaoke/UI/DrawableNoteJudgement.cs b/osu.Game.Rulesets.Karaoke/UI/DrawableNoteJudgement.cs index ea69ad890..321bb0973 100644 --- a/osu.Game.Rulesets.Karaoke/UI/DrawableNoteJudgement.cs +++ b/osu.Game.Rulesets.Karaoke/UI/DrawableNoteJudgement.cs @@ -5,46 +5,18 @@ using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Scoring; -using osuTK; namespace osu.Game.Rulesets.Karaoke.UI; public partial class DrawableNoteJudgement : DrawableJudgement { - public DrawableNoteJudgement(JudgementResult result, DrawableHitObject? judgedObject) + public DrawableNoteJudgement(JudgementResult result, DrawableHitObject judgedObject) : base(result, judgedObject) { } - protected override void ApplyMissAnimations() + public DrawableNoteJudgement() { - if (JudgementBody.Drawable is not DefaultKaraokeJudgementPiece) - { - // this is temporary logic until mania's skin transformer returns IAnimatableJudgements - JudgementBody.ScaleTo(1.6f); - JudgementBody.ScaleTo(1, 100, Easing.In); - - JudgementBody.MoveTo(Vector2.Zero); - JudgementBody.MoveToOffset(new Vector2(0, 100), 800, Easing.InQuint); - - JudgementBody.RotateTo(0); - JudgementBody.RotateTo(40, 800, Easing.InQuint); - JudgementBody.FadeOutFromOne(800); - - LifetimeEnd = JudgementBody.LatestTransformEndTime; - } - - base.ApplyMissAnimations(); - } - - protected override void ApplyHitAnimations() - { - JudgementBody.ScaleTo(0.8f); - JudgementBody.ScaleTo(1, 250, Easing.OutElastic); - - JudgementBody.Delay(50) - .ScaleTo(0.75f, 250) - .FadeOut(200); } protected override Drawable CreateDefaultJudgement(HitResult result) => new DefaultKaraokeJudgementPiece(result); @@ -62,5 +34,27 @@ protected override void LoadComplete() JudgementText.Font = JudgementText.Font.With(size: 25); } + + public override void PlayAnimation() + { + switch (Result) + { + case HitResult.None: + case HitResult.Miss: + base.PlayAnimation(); + break; + + default: + this.ScaleTo(0.8f); + this.ScaleTo(1, 250, Easing.OutElastic); + + this.Delay(50) + .ScaleTo(0.75f, 250) + .FadeOut(200); + + // osu!mania uses a custom fade length, so the base call is intentionally omitted. + break; + } + } } } From ec366b7a916157f672f7cfba7c05e9d86e1ef662 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Tue, 25 Jun 2024 21:50:22 +0800 Subject: [PATCH 3/6] Upgrade package to the latest and fix the compile error. --- .../Graphics/UserInterfaceV2/LabelledRealTimeSliderBar.cs | 4 ++-- .../Graphics/UserInterfaceV2/LanguageSelector.cs | 2 +- .../Components/UserInterfaceV2/LanguageSelectorPopover.cs | 2 +- .../Edit/Beatmaps/Components/UserInterfaceV2/LyricSelector.cs | 2 +- .../Components/Lyrics/Blueprints/RubyTagSelectionBlueprint.cs | 2 +- .../Components/Lyrics/Carets/DrawableCreateRubyTagCaret.cs | 4 ++-- .../Lyrics/Components/Lyrics/Carets/DrawableTypingCaret.cs | 2 +- .../Lyrics/Compose/BottomEditor/Notes/NoteEditPopover.cs | 2 +- .../Beatmaps/Lyrics/Settings/LabelledObjectFieldTextBox.cs | 2 +- .../Settings/Reference/LabelledReferenceLyricSelector.cs | 2 +- osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj | 2 +- 11 files changed, 13 insertions(+), 13 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Graphics/UserInterfaceV2/LabelledRealTimeSliderBar.cs b/osu.Game.Rulesets.Karaoke/Graphics/UserInterfaceV2/LabelledRealTimeSliderBar.cs index 8816d9fd7..ec816d46e 100644 --- a/osu.Game.Rulesets.Karaoke/Graphics/UserInterfaceV2/LabelledRealTimeSliderBar.cs +++ b/osu.Game.Rulesets.Karaoke/Graphics/UserInterfaceV2/LabelledRealTimeSliderBar.cs @@ -1,15 +1,15 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. -using System; using osu.Framework.Graphics; using osu.Game.Graphics.UserInterfaceV2; using osu.Game.Overlays.Settings; +using System.Numerics; namespace osu.Game.Rulesets.Karaoke.Graphics.UserInterfaceV2; public partial class LabelledRealTimeSliderBar : LabelledSliderBar - where TNumber : struct, IEquatable, IComparable, IConvertible + where TNumber : struct, INumber, IMinMaxValue { protected override SettingsSlider CreateComponent() => base.CreateComponent().With(x => x.TransferValueOnCommit = false); diff --git a/osu.Game.Rulesets.Karaoke/Graphics/UserInterfaceV2/LanguageSelector.cs b/osu.Game.Rulesets.Karaoke/Graphics/UserInterfaceV2/LanguageSelector.cs index 52b378d43..b093fe877 100644 --- a/osu.Game.Rulesets.Karaoke/Graphics/UserInterfaceV2/LanguageSelector.cs +++ b/osu.Game.Rulesets.Karaoke/Graphics/UserInterfaceV2/LanguageSelector.cs @@ -85,7 +85,7 @@ protected override void OnFocus(FocusEvent e) { base.OnFocus(e); - GetContainingInputManager().ChangeFocus(filter); + GetContainingFocusManager().ChangeFocus(filter); } private bool enableEmptyOption; diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Components/UserInterfaceV2/LanguageSelectorPopover.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Components/UserInterfaceV2/LanguageSelectorPopover.cs index 0688d849b..11b414988 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Components/UserInterfaceV2/LanguageSelectorPopover.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Components/UserInterfaceV2/LanguageSelectorPopover.cs @@ -32,6 +32,6 @@ protected override void LoadComplete() { base.LoadComplete(); - GetContainingInputManager().ChangeFocus(languageSelector); + GetContainingFocusManager().ChangeFocus(languageSelector); } } diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Components/UserInterfaceV2/LyricSelector.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Components/UserInterfaceV2/LyricSelector.cs index 9847efde4..a966c85ee 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Components/UserInterfaceV2/LyricSelector.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Components/UserInterfaceV2/LyricSelector.cs @@ -87,7 +87,7 @@ protected override void OnFocus(FocusEvent e) { base.OnFocus(e); - GetContainingInputManager().ChangeFocus(filter); + GetContainingFocusManager().ChangeFocus(filter); } private partial class LyricSelectionSearchTextBox : SearchTextBox diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/RubyTagSelectionBlueprint.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/RubyTagSelectionBlueprint.cs index de3c78cc2..afb9ca999 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/RubyTagSelectionBlueprint.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/RubyTagSelectionBlueprint.cs @@ -214,7 +214,7 @@ void deleteRubyText() protected override void LoadComplete() { base.LoadComplete(); - ScheduleAfterChildren(() => GetContainingInputManager().ChangeFocus(labelledRubyTextBox)); + ScheduleAfterChildren(() => GetContainingFocusManager().ChangeFocus(labelledRubyTextBox)); } private partial class DeleteRubyButton : EditorSectionButton diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Carets/DrawableCreateRubyTagCaret.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Carets/DrawableCreateRubyTagCaret.cs index 6f8f12d77..4f04300ef 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Carets/DrawableCreateRubyTagCaret.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Carets/DrawableCreateRubyTagCaret.cs @@ -191,7 +191,7 @@ private void addRubyText() if (string.IsNullOrEmpty(rubyText)) { labelledRubyTextBox.Description = "Please enter the ruby text"; - GetContainingInputManager().ChangeFocus(labelledRubyTextBox); + GetContainingFocusManager().ChangeFocus(labelledRubyTextBox); return; } @@ -208,7 +208,7 @@ private void addRubyText() protected override void LoadComplete() { base.LoadComplete(); - ScheduleAfterChildren(() => GetContainingInputManager().ChangeFocus(labelledRubyTextBox)); + ScheduleAfterChildren(() => GetContainingFocusManager().ChangeFocus(labelledRubyTextBox)); } private partial class CreateRubyLabelledTextBox : LabelledTextBox diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Carets/DrawableTypingCaret.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Carets/DrawableTypingCaret.cs index 2c13ab474..ff45e94de 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Carets/DrawableTypingCaret.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Carets/DrawableTypingCaret.cs @@ -178,7 +178,7 @@ public void FocusInputCaretTextBox() Schedule(() => { inputCaretTextBox.Text = string.Empty; - GetContainingInputManager().ChangeFocus(inputCaretTextBox); + GetContainingFocusManager().ChangeFocus(inputCaretTextBox); }); } } diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Compose/BottomEditor/Notes/NoteEditPopover.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Compose/BottomEditor/Notes/NoteEditPopover.cs index f19f11076..8dc28b8f9 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Compose/BottomEditor/Notes/NoteEditPopover.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Compose/BottomEditor/Notes/NoteEditPopover.cs @@ -75,7 +75,7 @@ public NoteSection(Note note) ScheduleAfterChildren(() => { - GetContainingInputManager().ChangeFocus(text); + GetContainingFocusManager().ChangeFocus(text); }); text.OnCommit += (sender, newText) => diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/LabelledObjectFieldTextBox.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/LabelledObjectFieldTextBox.cs index 57b4b988c..7f516ed47 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/LabelledObjectFieldTextBox.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/LabelledObjectFieldTextBox.cs @@ -99,7 +99,7 @@ private void focus() if (IsFocused(focusedDrawable)) return; - GetContainingInputManager().ChangeFocus(Component); + GetContainingFocusManager().ChangeFocus(Component); }); } diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Reference/LabelledReferenceLyricSelector.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Reference/LabelledReferenceLyricSelector.cs index 2b72ed761..a64d4b1a9 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Reference/LabelledReferenceLyricSelector.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/Reference/LabelledReferenceLyricSelector.cs @@ -105,7 +105,7 @@ protected override void LoadComplete() { base.LoadComplete(); - GetContainingInputManager().ChangeFocus(lyricSelector); + GetContainingFocusManager().ChangeFocus(lyricSelector); } } diff --git a/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj b/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj index ae05555ae..502e6083b 100644 --- a/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj +++ b/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj @@ -17,7 +17,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + From 25686b05101dab6561f16353dfea5e2732c05dce Mon Sep 17 00:00:00 2001 From: andy840119 Date: Tue, 25 Jun 2024 22:08:37 +0800 Subject: [PATCH 4/6] Upgrade the lazer to the latest. --- .../ChangeHandlers/BaseChangeHandlerTest.cs | 4 ++++ .../Blueprints/RubyBlueprintContainer.cs | 2 +- .../Beatmaps/Lyrics/Compose/LyricComposer.cs | 5 +---- .../Settings/LabelledObjectFieldTextBox.cs | 3 +++ .../Skinning/Legacy/LegacyHitExplosion.cs | 5 +---- .../Skinning/Legacy/LegacyNotePiece.cs | 20 ++++--------------- .../UI/DrawableNoteJudgement.cs | 2 +- .../osu.Game.Rulesets.Karaoke.csproj | 2 +- 8 files changed, 16 insertions(+), 27 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/Editor/ChangeHandlers/BaseChangeHandlerTest.cs b/osu.Game.Rulesets.Karaoke.Tests/Editor/ChangeHandlers/BaseChangeHandlerTest.cs index 761f9b9dd..3e9c8f400 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Editor/ChangeHandlers/BaseChangeHandlerTest.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Editor/ChangeHandlers/BaseChangeHandlerTest.cs @@ -251,6 +251,10 @@ public MockEditorChangeHandler(EditorBeatmap editorBeatmap) editorBeatmap.SaveStateTriggered += SaveState; } + public void RestoreState(int direction) + { + } + protected override void UpdateState() { OnStateChange?.Invoke(); diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/RubyBlueprintContainer.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/RubyBlueprintContainer.cs index 999934d26..537ecd3dd 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/RubyBlueprintContainer.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Components/Lyrics/Blueprints/RubyBlueprintContainer.cs @@ -49,7 +49,7 @@ protected override void OnSelectionChanged() base.OnSelectionChanged(); // only select one ruby tag can let user drag to change start and end index. - SelectionBox.CanScaleX = SelectedItems.Count == 1; + ScaleHandler.CanScaleX.Value = SelectedItems.Count == 1; // should clear delta size before change start/end index. deltaScaleSize = 0; diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Compose/LyricComposer.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Compose/LyricComposer.cs index 61b847bb8..8652bfdd8 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Compose/LyricComposer.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Compose/LyricComposer.cs @@ -304,11 +304,8 @@ private void assignBottomEditor(BottomEditorType? bottomEditorType) const double new_animation_time = 200; bool hasOldButtonEditor = bottomEditorContainer.Children.Any(); - var newButtonEditor = createBottomEditor(bottomEditorType).With(x => + var newButtonEditor = createBottomEditor(bottomEditorType)?.With(x => { - if (x == null) - return; - x.RelativePositionAxes = Axes.Y; x.Y = -1; x.Alpha = 0; diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/LabelledObjectFieldTextBox.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/LabelledObjectFieldTextBox.cs index 7f516ed47..475a7bf7e 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/LabelledObjectFieldTextBox.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Beatmaps/Lyrics/Settings/LabelledObjectFieldTextBox.cs @@ -94,6 +94,9 @@ private void focus() // Make sure that view is visible in the scroll container. // Give the top spacing larger space to let use able to see the previous item or the description text. var parentScrollContainer = this.FindClosestParent(); + if (parentScrollContainer == null) + throw new InvalidOperationException("Should have a parent scroll container."); + parentScrollContainer.ScrollIntoViewWithSpacing(this, new MarginPadding { Top = 150, Bottom = 50 }); if (IsFocused(focusedDrawable)) diff --git a/osu.Game.Rulesets.Karaoke/Skinning/Legacy/LegacyHitExplosion.cs b/osu.Game.Rulesets.Karaoke/Skinning/Legacy/LegacyHitExplosion.cs index 166b1ad12..0a69ca7fa 100644 --- a/osu.Game.Rulesets.Karaoke/Skinning/Legacy/LegacyHitExplosion.cs +++ b/osu.Game.Rulesets.Karaoke/Skinning/Legacy/LegacyHitExplosion.cs @@ -39,11 +39,8 @@ private void load(ISkinSource skin, IScrollingInfo scrollingInfo) if (tmp is IFramedAnimation { FrameCount: > 0 } tmpAnimation) frameLength = Math.Max(1000 / 60.0, 170.0 / tmpAnimation.FrameCount); - explosion = skin.GetAnimation(imageName, true, false, frameLength: frameLength).With(d => + explosion = skin.GetAnimation(imageName, true, false, frameLength: frameLength)?.With(d => { - if (d == null) - return; - d.Origin = Anchor.Centre; d.Blending = BlendingParameters.Additive; d.Scale = new Vector2(explosionScale); diff --git a/osu.Game.Rulesets.Karaoke/Skinning/Legacy/LegacyNotePiece.cs b/osu.Game.Rulesets.Karaoke/Skinning/Legacy/LegacyNotePiece.cs index 5e04d7795..8e004bcbe 100644 --- a/osu.Game.Rulesets.Karaoke/Skinning/Legacy/LegacyNotePiece.cs +++ b/osu.Game.Rulesets.Karaoke/Skinning/Legacy/LegacyNotePiece.cs @@ -140,20 +140,14 @@ private LayerContainer createLayer(string name, ISkin skin, LegacyKaraokeSkinNot Name = name, Children = new[] { - getSpriteFromLookup(skin, LegacyKaraokeSkinConfigurationLookups.NoteHeadImage, layer).With(d => + getSpriteFromLookup(skin, LegacyKaraokeSkinConfigurationLookups.NoteHeadImage, layer)?.With(d => { - if (d == null) - return; - d.Name = "Head"; d.Anchor = Anchor.CentreLeft; d.Origin = Anchor.Centre; }), - getSpriteFromLookup(skin, LegacyKaraokeSkinConfigurationLookups.NoteBodyImage, layer).With(d => + getSpriteFromLookup(skin, LegacyKaraokeSkinConfigurationLookups.NoteBodyImage, layer)?.With(d => { - if (d == null) - return; - d.Name = "Body"; d.Anchor = Anchor.Centre; d.Origin = Anchor.Centre; @@ -164,11 +158,8 @@ private LayerContainer createLayer(string name, ISkin skin, LegacyKaraokeSkinNot d.Height = d.Texture?.DisplayHeight ?? 0; }), - getSpriteFromLookup(skin, LegacyKaraokeSkinConfigurationLookups.NoteTailImage, layer).With(d => + getSpriteFromLookup(skin, LegacyKaraokeSkinConfigurationLookups.NoteTailImage, layer)?.With(d => { - if (d == null) - return; - d.Name = "Tail"; d.Anchor = Anchor.CentreRight; d.Origin = Anchor.Centre; @@ -195,13 +186,10 @@ private LayerContainer createLayer(string name, ISkin skin, LegacyKaraokeSkinNot return null; } - Sprite? getSpriteByName(string spriteName) => (Sprite?)skin.GetAnimation(spriteName, true, true).With(d => + Sprite? getSpriteByName(string spriteName) => (Sprite?)skin.GetAnimation(spriteName, true, true)?.With(d => { switch (d) { - case null: - return; - case TextureAnimation animation: animation.IsPlaying = false; break; diff --git a/osu.Game.Rulesets.Karaoke/UI/DrawableNoteJudgement.cs b/osu.Game.Rulesets.Karaoke/UI/DrawableNoteJudgement.cs index 321bb0973..6567cebbd 100644 --- a/osu.Game.Rulesets.Karaoke/UI/DrawableNoteJudgement.cs +++ b/osu.Game.Rulesets.Karaoke/UI/DrawableNoteJudgement.cs @@ -52,7 +52,7 @@ public override void PlayAnimation() .ScaleTo(0.75f, 250) .FadeOut(200); - // osu!mania uses a custom fade length, so the base call is intentionally omitted. + // karaoke uses a custom fade length, so the base call is intentionally omitted. break; } } diff --git a/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj b/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj index 502e6083b..8b8c92c45 100644 --- a/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj +++ b/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj @@ -17,7 +17,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + From 96a8f1a54dbb1791f1475e952bd6148b3e82fdb7 Mon Sep 17 00:00:00 2001 From: andy840119 Date: Tue, 25 Jun 2024 22:11:38 +0800 Subject: [PATCH 5/6] Upgrade remaining package to the latest. --- .../osu.Game.Rulesets.Karaoke.Architectures.csproj | 2 +- osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Architectures/osu.Game.Rulesets.Karaoke.Architectures.csproj b/osu.Game.Rulesets.Karaoke.Architectures/osu.Game.Rulesets.Karaoke.Architectures.csproj index 08486b3e8..7bcd25024 100644 --- a/osu.Game.Rulesets.Karaoke.Architectures/osu.Game.Rulesets.Karaoke.Architectures.csproj +++ b/osu.Game.Rulesets.Karaoke.Architectures/osu.Game.Rulesets.Karaoke.Architectures.csproj @@ -11,7 +11,7 @@ - + diff --git a/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj b/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj index 8b8c92c45..7b401fc9b 100644 --- a/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj +++ b/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj @@ -10,7 +10,7 @@ - + From 59b2a55ac75fc3d16c4548ee4aa868b91a169fca Mon Sep 17 00:00:00 2001 From: andy840119 Date: Tue, 25 Jun 2024 22:53:06 +0800 Subject: [PATCH 6/6] Fix the test case failed. --- .../Beatmaps/KaraokeBeatmapProcessor.cs | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmapProcessor.cs b/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmapProcessor.cs index 487a4dfd7..f631e52a1 100644 --- a/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmapProcessor.cs +++ b/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmapProcessor.cs @@ -1,6 +1,7 @@ // Copyright (c) andy840119 . Licensed under the GPL Licence. // See the LICENCE file in the repository root for full licence text. +using System; using System.Linq; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Game.Beatmaps; @@ -10,13 +11,12 @@ using osu.Game.Rulesets.Karaoke.Stages; using osu.Game.Rulesets.Karaoke.Stages.Preview; using osu.Game.Rulesets.Karaoke.Stages.Types; +using osu.Game.Screens.Edit; namespace osu.Game.Rulesets.Karaoke.Beatmaps; public class KaraokeBeatmapProcessor : BeatmapProcessor { - public new KaraokeBeatmap Beatmap => (KaraokeBeatmap)base.Beatmap; - public KaraokeBeatmapProcessor(IBeatmap beatmap) : base(beatmap) { @@ -24,10 +24,24 @@ public KaraokeBeatmapProcessor(IBeatmap beatmap) public override void PreProcess() { - applyStage(Beatmap); + var karaokeBeatmap = getKaraokeBeatmap(Beatmap); + applyStage(karaokeBeatmap); base.PreProcess(); - applyInvalidProperty(Beatmap); + applyInvalidProperty(karaokeBeatmap); + + static KaraokeBeatmap getKaraokeBeatmap(IBeatmap beatmap) + { + // goes to there while parsing the beatmap. + if (beatmap is KaraokeBeatmap karaokeBeatmap) + return karaokeBeatmap; + + // goes to there while editing the beatmap. + if (beatmap is EditorBeatmap editorBeatmap) + return getKaraokeBeatmap(editorBeatmap.PlayableBeatmap); + + throw new InvalidCastException($"The beatmap is not a {nameof(KaraokeBeatmap)}"); + } } private void applyStage(KaraokeBeatmap beatmap) @@ -36,7 +50,7 @@ private void applyStage(KaraokeBeatmap beatmap) // trying to load the first stage or create a default one. if (beatmap.CurrentStageInfo == null) { - beatmap.CurrentStageInfo = getWorkingStage() ?? createDefaultWorkingStage(); + beatmap.CurrentStageInfo = getWorkingStage(beatmap) ?? createDefaultWorkingStage(); // should invalidate the working property here because the stage info is changed. beatmap.HitObjects.OfType().ForEach(x => @@ -50,10 +64,10 @@ private void applyStage(KaraokeBeatmap beatmap) if (beatmap.CurrentStageInfo is IHasCalculatedProperty calculatedProperty) calculatedProperty.ValidateCalculatedProperty(beatmap); - StageInfo? getWorkingStage() - => Beatmap.StageInfos.FirstOrDefault(); + static StageInfo? getWorkingStage(KaraokeBeatmap beatmap) + => beatmap.StageInfos.FirstOrDefault(); - StageInfo createDefaultWorkingStage() => new PreviewStageInfo(); + static StageInfo createDefaultWorkingStage() => new PreviewStageInfo(); } private void applyInvalidProperty(KaraokeBeatmap beatmap)