-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement the timing info and apply into the setting section.
- Loading branch information
1 parent
c28ea21
commit 29464af
Showing
2 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
osu.Game.Rulesets.Karaoke/Screens/Edit/Stages/Classic/Stage/Settings/TimingPointsSection.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// Copyright (c) andy840119 <[email protected]>. 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<ClassicLyricTimingPoint> | ||
{ | ||
[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<int> timingPointsVersion = new Bindable<int>(); | ||
|
||
[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); | ||
}; | ||
} | ||
} | ||
} | ||
} |