diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Stages/Classic/Stage/Settings/StageSettings.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Stages/Classic/Stage/Settings/StageSettings.cs index 767539a45..22ced18a4 100644 --- a/osu.Game.Rulesets.Karaoke/Screens/Edit/Stages/Classic/Stage/Settings/StageSettings.cs +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Stages/Classic/Stage/Settings/StageSettings.cs @@ -61,6 +61,7 @@ private void load(OverlayColourProvider colourProvider, IStageEditorStateProvide StageEditorEditMode.Edit => new Drawable[] { new StageEditorEditModeSection(StageEditorEditCategory.Timing), + new TimingPointsSection(), }, StageEditorEditMode.Verify => new Drawable[] { diff --git a/osu.Game.Rulesets.Karaoke/Screens/Edit/Stages/Classic/Stage/Settings/TimingPointsSection.cs b/osu.Game.Rulesets.Karaoke/Screens/Edit/Stages/Classic/Stage/Settings/TimingPointsSection.cs new file mode 100644 index 000000000..1b355b8bf --- /dev/null +++ b/osu.Game.Rulesets.Karaoke/Screens/Edit/Stages/Classic/Stage/Settings/TimingPointsSection.cs @@ -0,0 +1,87 @@ +// Copyright (c) andy840119 . Licensed under the GPL Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Diagnostics.CodeAnalysis; +using osu.Framework.Allocation; +using osu.Framework.Bindables; +using osu.Framework.Localisation; +using osu.Game.Extensions; +using osu.Game.Rulesets.Karaoke.Beatmaps.Stages.Classic; +using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Beatmaps; +using osu.Game.Screens.Edit; + +namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Stages.Classic.Stage.Settings; + +public partial class TimingPointsSection : EditorSection +{ + protected override LocalisableString Title => "Timings"; + + public TimingPointsSection() + { + Add(new SectionPageInfoEditor()); + } + + private partial class SectionPageInfoEditor : SectionTimingInfoItemsEditor + { + [BackgroundDependencyLoader] + private void load(IStageEditorStateProvider stageEditorStateProvider) + { + Items.BindTo(stageEditorStateProvider.StageInfo.LyricTimingInfo.Timings); + } + + protected override DrawableTimingInfoItem CreateTimingInfoDrawable(ClassicLyricTimingPoint item) => new DrawableTimingPoint(item); + + protected override EditorSectionButton? CreateCreateNewItemButton() => new CreateNewTimingPointButton(); + + private partial class DrawableTimingPoint : DrawableTimingInfoItem + { + private readonly IBindable timingPointsVersion = new Bindable(); + + [Resolved, AllowNull] + private IBeatmapClassicStageChangeHandler beatmapClassicStageChangeHandler { get; set; } + + public DrawableTimingPoint(ClassicLyricTimingPoint item) + : base(item) + { + } + + protected override void RemoveItem(ClassicLyricTimingPoint item) + { + beatmapClassicStageChangeHandler.RemoveTimingPoint(item); + } + + [BackgroundDependencyLoader] + private void load(IStageEditorStateProvider stageEditorStateProvider) + { + timingPointsVersion.BindTo(stageEditorStateProvider.StageInfo.LyricTimingInfo.TimingVersion); + timingPointsVersion.BindValueChanged(_ => + { + int? order = stageEditorStateProvider.StageInfo.LyricTimingInfo.GetTimingPointOrder(Item); + double time = Item.Time; + + ChangeDisplayOrder((int)time); + Text = $"#{order} {time.ToEditorFormattedString()}"; + }, true); + } + } + + private partial class CreateNewTimingPointButton : EditorSectionButton + { + [Resolved, AllowNull] + private IBeatmapClassicStageChangeHandler beatmapClassicStageChangeHandler { get; set; } + + [Resolved, AllowNull] + private EditorClock clock { get; set; } + + public CreateNewTimingPointButton() + { + Text = "Create new timing"; + Action = () => + { + double currentTime = clock.CurrentTime; + beatmapClassicStageChangeHandler.AddTimingPoint(x => x.Time = currentTime); + }; + } + } + } +}