diff --git a/osu.Game.Rulesets.Karaoke.Tests/Skinning/TestSceneLyric.cs b/osu.Game.Rulesets.Karaoke.Tests/Skinning/TestSceneLyric.cs index ade6b948d..9b92b851c 100644 --- a/osu.Game.Rulesets.Karaoke.Tests/Skinning/TestSceneLyric.cs +++ b/osu.Game.Rulesets.Karaoke.Tests/Skinning/TestSceneLyric.cs @@ -10,9 +10,11 @@ using osu.Framework.Graphics.Sprites; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; +using osu.Game.Rulesets.Karaoke.Beatmaps.Stages.Preview; using osu.Game.Rulesets.Karaoke.Configuration; using osu.Game.Rulesets.Karaoke.Objects; using osu.Game.Rulesets.Karaoke.Objects.Drawables; +using osu.Game.Rulesets.Karaoke.Objects.Stages.Preview; using osu.Game.Rulesets.Mods; namespace osu.Game.Rulesets.Karaoke.Tests.Skinning; @@ -83,6 +85,18 @@ private Drawable testSingle(double timeOffset = 0) Text = "ke" } }, + EffectApplier = new LyricPreviewStageEffectApplier(new[] + { + new PreviewLyricLayout(1) + { + StartTime = startTime, + EndTime = startTime + duration, + Timings = new Dictionary + { + { 0, startTime } + } + } + }, new PreviewStageDefinition()) }; lyric.Translates.Add(cultureInfo, "karaoke"); diff --git a/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmapProcessor.cs b/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmapProcessor.cs index e082ad297..386a19ecc 100644 --- a/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmapProcessor.cs +++ b/osu.Game.Rulesets.Karaoke/Beatmaps/KaraokeBeatmapProcessor.cs @@ -4,11 +4,9 @@ using System.Linq; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Game.Beatmaps; -using osu.Game.Rulesets.Karaoke.Beatmaps.Patterns; using osu.Game.Rulesets.Karaoke.Beatmaps.Stages; using osu.Game.Rulesets.Karaoke.Beatmaps.Stages.Preview; using osu.Game.Rulesets.Karaoke.Beatmaps.Stages.Types; -using osu.Game.Rulesets.Karaoke.Objects; using osu.Game.Rulesets.Karaoke.Objects.Types; using osu.Game.Rulesets.Karaoke.Objects.Workings; @@ -62,18 +60,5 @@ private void applyInvalidProperty(KaraokeBeatmap beatmap) hitObject.ValidateWorkingProperty(beatmap); } } - - public override void PostProcess() - { - base.PostProcess(); - - var lyrics = Beatmap.HitObjects.OfType().ToList(); - - if (!lyrics.Any()) - return; - - var pattern = new LegacyLyricTimeGenerator(); - pattern.Generate(lyrics); - } } } diff --git a/osu.Game.Rulesets.Karaoke/Beatmaps/Patterns/IPatternGenerator.cs b/osu.Game.Rulesets.Karaoke/Beatmaps/Patterns/IPatternGenerator.cs deleted file mode 100644 index c54ca47c7..000000000 --- a/osu.Game.Rulesets.Karaoke/Beatmaps/Patterns/IPatternGenerator.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) andy840119 . Licensed under the GPL Licence. -// See the LICENCE file in the repository root for full licence text. - -using System.Collections.Generic; -using osu.Game.Rulesets.Karaoke.Objects; - -namespace osu.Game.Rulesets.Karaoke.Beatmaps.Patterns -{ - public interface IPatternGenerator where TObject : KaraokeHitObject - { - void Generate(IEnumerable hitObjects); - } -} diff --git a/osu.Game.Rulesets.Karaoke/Beatmaps/Patterns/LegacyLyricTimeGenerator.cs b/osu.Game.Rulesets.Karaoke/Beatmaps/Patterns/LegacyLyricTimeGenerator.cs deleted file mode 100644 index 7d5021af2..000000000 --- a/osu.Game.Rulesets.Karaoke/Beatmaps/Patterns/LegacyLyricTimeGenerator.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) andy840119 . Licensed under the GPL Licence. -// See the LICENCE file in the repository root for full licence text. - -using System.Collections.Generic; -using System.Linq; -using osu.Game.Rulesets.Karaoke.Objects; - -namespace osu.Game.Rulesets.Karaoke.Beatmaps.Patterns -{ - /// - /// Note: this class will be replaced by another lyric-time generator. - /// - public class LegacyLyricTimeGenerator : IPatternGenerator - { - private const int number_of_line = 2; - - public void Generate(IEnumerable hitObjects) - { - var lyrics = hitObjects.ToList(); - - // Re-assign time - assignLyricTime(lyrics); - } - - private void assignLyricTime(IList lyrics) - { - // Apply start time - for (int i = 0; i < lyrics.Count; i++) - { - var lastLyric = i >= number_of_line ? lyrics[i - number_of_line] : null; - var lyric = lyrics[i]; - - if (lastLyric == null) - continue; - - double lyricEndTime = lyric.LyricEndTime; - double lyricStartTime = lastLyric.EndTime + 1000; - - // Adjust start time and end time - lyric.StartTime = lyricStartTime; - lyric.Duration = lyricEndTime - lyricStartTime; - } - } - } -} diff --git a/osu.Game.Rulesets.Karaoke/Edit/KaraokeEditorPlayfield.cs b/osu.Game.Rulesets.Karaoke/Edit/KaraokeEditorPlayfield.cs index 8b3851465..84e8479f6 100644 --- a/osu.Game.Rulesets.Karaoke/Edit/KaraokeEditorPlayfield.cs +++ b/osu.Game.Rulesets.Karaoke/Edit/KaraokeEditorPlayfield.cs @@ -3,22 +3,13 @@ #nullable disable -using osu.Framework.Graphics; using osu.Game.Rulesets.Karaoke.UI; using osu.Game.Rulesets.Karaoke.UI.Scrolling; -using osuTK; namespace osu.Game.Rulesets.Karaoke.Edit { public partial class KaraokeEditorPlayfield : KaraokePlayfield { - public KaraokeEditorPlayfield() - { - LyricPlayfield.Anchor = LyricPlayfield.Origin = Anchor.BottomCentre; - LyricPlayfield.Margin = new MarginPadding { Top = 150, Bottom = -100 }; - LyricPlayfield.Scale = new Vector2(0.7f); - } - protected override ScrollingNotePlayfield CreateNotePlayfield(int columns) => new EditorNotePlayfield(columns); } diff --git a/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableKaraokeHitObject.cs b/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableKaraokeHitObject.cs index d331e025f..2d6745d46 100644 --- a/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableKaraokeHitObject.cs +++ b/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableKaraokeHitObject.cs @@ -5,6 +5,7 @@ using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Karaoke.Judgements; +using osu.Game.Rulesets.Karaoke.Objects.Types; using osu.Game.Rulesets.Objects.Drawables; namespace osu.Game.Rulesets.Karaoke.Objects.Drawables @@ -16,8 +17,43 @@ protected DrawableKaraokeHitObject(KaraokeHitObject hitObject) { } - protected sealed override double InitialLifetimeOffset => HitObject.TimePreempt; + protected sealed override double InitialLifetimeOffset + { + get + { + if (HitObject is IHasEffectApplier hitObjectWithEffectApplier) + { + return hitObjectWithEffectApplier.EffectApplier.PreemptTime; + } + + return base.InitialLifetimeOffset; + } + } protected override JudgementResult CreateResult(Judgement judgement) => new KaraokeJudgementResult(HitObject, judgement); + + protected override void UpdateInitialTransforms() + { + if (HitObject is IHasEffectApplier hitObjectWithEffectApplier) + { + hitObjectWithEffectApplier.EffectApplier.UpdateInitialTransforms(this); + } + } + + protected override void UpdateStartTimeStateTransforms() + { + if (HitObject is IHasEffectApplier hitObjectWithEffectApplier) + { + hitObjectWithEffectApplier.EffectApplier.UpdateStartTimeStateTransforms(this); + } + } + + protected override void UpdateHitStateTransforms(ArmedState state) + { + if (HitObject is IHasEffectApplier hitObjectWithEffectApplier) + { + hitObjectWithEffectApplier.EffectApplier.UpdateHitStateTransforms(this, state); + } + } } } diff --git a/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableLyric.cs b/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableLyric.cs index 1b4b86524..1db5f0d67 100644 --- a/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableLyric.cs +++ b/osu.Game.Rulesets.Karaoke/Objects/Drawables/DrawableLyric.cs @@ -18,9 +18,7 @@ using osu.Game.Rulesets.Karaoke.Scoring; using osu.Game.Rulesets.Karaoke.Skinning.Default; using osu.Game.Rulesets.Karaoke.Skinning.Elements; -using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Skinning; -using osuTK; namespace osu.Game.Rulesets.Karaoke.Objects.Drawables { @@ -60,14 +58,11 @@ public DrawableLyric() public DrawableLyric([CanBeNull] Lyric hitObject) : base(hitObject) { - // todo: it's a reservable size, should be removed eventually. - Padding = new MarginPadding(30); } [BackgroundDependencyLoader(true)] private void load([CanBeNull] KaraokeSessionStatics session) { - Scale = new Vector2(2); AutoSizeAxes = Axes.Both; AddInternal(lyricPieces = new Container @@ -150,7 +145,6 @@ protected override void ApplySkin(ISkinSource skin, bool allowFallback) updateFontStyle(); updateLyricFontInfo(); - updateLayout(); } private void updateFontStyle() @@ -177,18 +171,6 @@ private void updateLyricFontInfo() lyricFontInfo?.ApplyTo(this); } - private void updateLayout() - { - if (CurrentSkin == null) - return; - - if (HitObject == null) - return; - - var layout = CurrentSkin.GetConfig(HitObject)?.Value; - layout?.ApplyTo(this); - } - private void applyTranslate() { var language = preferLanguageBindable.Value; @@ -231,14 +213,6 @@ protected override void UpdateInitialTransforms() lyricPieces.ForEach(x => x.RefreshStateTransforms()); } - protected override void UpdateHitStateTransforms(ArmedState state) - { - base.UpdateHitStateTransforms(state); - - const float fade_out_time = 500; - this.FadeOut(fade_out_time); - } - public void ApplyToLyricPieces(Action action) { foreach (var lyricPiece in lyricPieces) diff --git a/osu.Game.Rulesets.Karaoke/UI/DrawableKaraokeRuleset.cs b/osu.Game.Rulesets.Karaoke/UI/DrawableKaraokeRuleset.cs index 03784ddb7..e648521a7 100644 --- a/osu.Game.Rulesets.Karaoke/UI/DrawableKaraokeRuleset.cs +++ b/osu.Game.Rulesets.Karaoke/UI/DrawableKaraokeRuleset.cs @@ -45,6 +45,8 @@ public partial class DrawableKaraokeRuleset : DrawableScrollingRuleset base.Beatmap as KaraokeBeatmap; + protected virtual bool DisplayNotePlayfield => Beatmap.IsScorable(); public DrawableKaraokeRuleset(Ruleset ruleset, IBeatmap beatmap, IReadOnlyList mods) @@ -70,6 +72,10 @@ protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnl [BackgroundDependencyLoader] private void load() { + // todo: use better way to assign the stage info. + // also, should monitor the stage info change. + updatePlayfieldArrangement(Beatmap.CurrentStageInfo); + // TODO : it should be moved into NotePlayfield new BarLineGenerator(Beatmap).BarLines.ForEach(bar => base.Playfield.Add(bar)); diff --git a/osu.Game.Rulesets.Karaoke/UI/DrawableKaraokeRuleset_Stage.cs b/osu.Game.Rulesets.Karaoke/UI/DrawableKaraokeRuleset_Stage.cs new file mode 100644 index 000000000..74c4c0b07 --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/UI/DrawableKaraokeRuleset_Stage.cs @@ -0,0 +1,19 @@ +// Copyright (c) andy840119 . Licensed under the GPL Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Bindables; +using osu.Game.Rulesets.Karaoke.Beatmaps.Stages; + +namespace osu.Game.Rulesets.Karaoke.UI; + +public partial class DrawableKaraokeRuleset +{ + private readonly IBindable currentStageInfo = new Bindable(); + private readonly IBindable scorable = new Bindable(); + + private void updatePlayfieldArrangement(StageInfo stageInfo) + { + var applier = stageInfo.GetPlayfieldStageApplier(); + applier.UpdatePlayfieldArrangement(Playfield, DisplayNotePlayfield); + } +} diff --git a/osu.Game.Rulesets.Karaoke/UI/KaraokePlayfield.cs b/osu.Game.Rulesets.Karaoke/UI/KaraokePlayfield.cs index 0753ded24..558a463c7 100644 --- a/osu.Game.Rulesets.Karaoke/UI/KaraokePlayfield.cs +++ b/osu.Game.Rulesets.Karaoke/UI/KaraokePlayfield.cs @@ -7,7 +7,6 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; using osu.Game.Beatmaps; using osu.Game.Rulesets.Karaoke.Beatmaps; using osu.Game.Rulesets.Karaoke.Configuration; @@ -49,16 +48,10 @@ public KaraokePlayfield() x.RelativeSizeAxes = Axes.Both; })); - AddInternal(new Container + AddInternal(NotePlayfield = CreateNotePlayfield(9).With(x => { - Padding = new MarginPadding(50), - RelativeSizeAxes = Axes.Both, - Child = NotePlayfield = CreateNotePlayfield(9).With(x => - { - x.Alpha = 0; - x.RelativeSizeAxes = Axes.X; - }) - }); + x.RelativeSizeAxes = Axes.X; + })); AddNested(LyricPlayfield); AddNested(NotePlayfield); diff --git a/osu.Game.Rulesets.Karaoke/UI/LyricPlayfield.cs b/osu.Game.Rulesets.Karaoke/UI/LyricPlayfield.cs index bf852fa3e..23d77a020 100644 --- a/osu.Game.Rulesets.Karaoke/UI/LyricPlayfield.cs +++ b/osu.Game.Rulesets.Karaoke/UI/LyricPlayfield.cs @@ -71,12 +71,12 @@ public LyricHitObjectLifetimeEntry(HitObject hitObject) { // Manually set to reduce the number of future alive objects to a bare minimum. LifetimeEnd = Lyric.EndTime; - LifetimeStart = HitObject.StartTime - Lyric.TimePreempt; + LifetimeStart = HitObject.StartTime - Lyric.EffectApplier.PreemptTime; } protected Lyric Lyric => (Lyric)HitObject; - protected override double InitialLifetimeOffset => Lyric.TimePreempt; + protected override double InitialLifetimeOffset => Lyric.EffectApplier.PreemptTime; } } }