From 62a1e8c60056b8007bcc8bff015c18b25b8c1d1d Mon Sep 17 00:00:00 2001 From: andy840119 Date: Fri, 16 Aug 2024 21:49:06 +0800 Subject: [PATCH] Upgrade the package and fix the compile error see: - https://github.com/ppy/osu/pull/26546/files - https://github.com/ppy/osu/pull/29406/files --- .../Skinning/TestSceneDrawableJudgement.cs | 22 ++++++++++++++----- .../UI/DrawableNoteJudgement.cs | 10 --------- osu.Game.Rulesets.Karaoke/UI/NotePlayfield.cs | 19 +++++++++++----- .../osu.Game.Rulesets.Karaoke.csproj | 2 +- 4 files changed, 32 insertions(+), 21 deletions(-) diff --git a/osu.Game.Rulesets.Karaoke.Tests/Skinning/TestSceneDrawableJudgement.cs b/osu.Game.Rulesets.Karaoke.Tests/Skinning/TestSceneDrawableJudgement.cs index bac4ff048..13f466743 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Skinning/TestSceneDrawableJudgement.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Skinning/TestSceneDrawableJudgement.cs @@ -19,12 +19,24 @@ 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 }, new DrawableNote()) + AddStep("Show " + result.GetDescription(), () => + { + SetContents(_ => { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - })); + var drawableManiaJudgement = new DrawableNoteJudgement + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }; + + drawableManiaJudgement.Apply(new JudgementResult(new HitObject { StartTime = Time.Current }, new Judgement()) + { + Type = result, + }, null); + + return drawableManiaJudgement; + }); + }); } } } diff --git a/osu.Game.Rulesets.Karaoke/UI/DrawableNoteJudgement.cs b/osu.Game.Rulesets.Karaoke/UI/DrawableNoteJudgement.cs index 6567cebbd..fa325e3d8 100644 --- a/osu.Game.Rulesets.Karaoke/UI/DrawableNoteJudgement.cs +++ b/osu.Game.Rulesets.Karaoke/UI/DrawableNoteJudgement.cs @@ -3,22 +3,12 @@ using osu.Framework.Graphics; using osu.Game.Rulesets.Judgements; -using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Scoring; namespace osu.Game.Rulesets.Karaoke.UI; public partial class DrawableNoteJudgement : DrawableJudgement { - public DrawableNoteJudgement(JudgementResult result, DrawableHitObject judgedObject) - : base(result, judgedObject) - { - } - - public DrawableNoteJudgement() - { - } - protected override Drawable CreateDefaultJudgement(HitResult result) => new DefaultKaraokeJudgementPiece(result); private partial class DefaultKaraokeJudgementPiece : DefaultJudgementPiece diff --git a/osu.Game.Rulesets.Karaoke/UI/NotePlayfield.cs b/osu.Game.Rulesets.Karaoke/UI/NotePlayfield.cs index de979a485..8369899e8 100644 --- a/osu.Game.Rulesets.Karaoke/UI/NotePlayfield.cs +++ b/osu.Game.Rulesets.Karaoke/UI/NotePlayfield.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.Allocation; using osu.Framework.Bindables; @@ -14,10 +15,12 @@ using osu.Game.Rulesets.Karaoke.Objects; using osu.Game.Rulesets.Karaoke.Objects.Drawables; using osu.Game.Rulesets.Karaoke.Replays; +using osu.Game.Rulesets.Karaoke.Scoring; using osu.Game.Rulesets.Karaoke.UI.Components; using osu.Game.Rulesets.Karaoke.UI.Position; using osu.Game.Rulesets.Karaoke.UI.Scrolling; using osu.Game.Rulesets.Objects.Drawables; +using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; using osu.Game.Skinning; using osuTK; @@ -33,6 +36,7 @@ public partial class NotePlayfield : ScrollingNotePlayfield, IKeyBindingHandler< private readonly Container judgementArea; private readonly JudgementContainer judgements; + private readonly JudgementPooler judgementPooler; private readonly Drawable judgementLine; private readonly ScoringMarker scoringMarker; @@ -121,6 +125,9 @@ public NotePlayfield(int columns) }); AddInternal(scoringStatus = new ScoringStatus(ScoringStatusMode.NotInitialized)); + + var hitWindows = new KaraokeNoteHitWindows(); + AddInternal(judgementPooler = new JudgementPooler(Enum.GetValues().Where(r => hitWindows.IsHitResultAllowed(r)))); } protected override void OnDirectionChanged(KaraokeScrollingDirection direction, float judgementAreaPercentage) @@ -186,12 +193,14 @@ internal void OnNewResult(DrawableHitObject judgedObject, JudgementResult result return; judgements.Clear(); - judgements.Add(new DrawableNoteJudgement(result, judgedObject) + judgements.Add(judgementPooler.Get(result.Type, j => { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Y = notePositionInfo.Calculator.YPositionAt(note.HitObject.Tone + 2), - }); + j.Apply(result, judgedObject); + + j.Y = notePositionInfo.Calculator.YPositionAt(note.HitObject.Tone + 2); + j.Anchor = Anchor.Centre; + j.Origin = Anchor.Centre; + })!); // Add hit explosion if (!result.IsHit) diff --git a/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj b/osu.Game.Rulesets.Karaoke/osu.Game.Rulesets.Karaoke.csproj index 47102df89..a8fa9a479 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 - +