-
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.
Merge pull request #1846 from andy840119/implement-timing-info-section
Implement timing info section.
- Loading branch information
Showing
9 changed files
with
143 additions
and
4 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
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
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
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
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
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
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); | ||
}; | ||
} | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,11 +1,17 @@ | ||
// Copyright (c) andy840119 <[email protected]>. Licensed under the GPL Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
using System; | ||
using System.Diagnostics.CodeAnalysis; | ||
using osu.Framework.Allocation; | ||
using osu.Framework.Bindables; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Graphics.Containers; | ||
using osu.Game.Rulesets.Karaoke.Beatmaps; | ||
using osu.Game.Rulesets.Karaoke.Beatmaps.Stages.Classic; | ||
using osu.Game.Rulesets.Karaoke.Edit.ChangeHandlers.Beatmaps; | ||
using osu.Game.Rulesets.Karaoke.Screens.Edit.Stages.Classic.Stage.Settings; | ||
using osu.Game.Screens.Edit; | ||
|
||
namespace osu.Game.Rulesets.Karaoke.Screens.Edit.Stages.Classic.Stage; | ||
|
||
|
@@ -18,12 +24,22 @@ public partial class StageScreen : ClassicStageScreen, IStageEditorStateProvider | |
private readonly Bindable<StageEditorEditCategory> bindableCategory = new(); | ||
private readonly Bindable<StageEditorEditMode> bindableEditMode = new(); | ||
|
||
[Cached(typeof(IBeatmapClassicStageChangeHandler))] | ||
private readonly BeatmapClassicStageChangeHandler beatmapClassicStageChangeHandler; | ||
|
||
[Cached(typeof(IStageEditorVerifier))] | ||
private readonly StageEditorVerifier stageEditorVerifier; | ||
|
||
[Resolved, AllowNull] | ||
private EditorBeatmap editorBeatmap { get; set; } | ||
|
||
public ClassicStageInfo StageInfo => (editorBeatmap.PlayableBeatmap as KaraokeBeatmap)!.GetStageInfo<ClassicStageInfo>() | ||
?? throw new InvalidOperationException(); | ||
|
||
public StageScreen() | ||
: base(ClassicStageEditorScreenMode.Stage) | ||
{ | ||
AddInternal(beatmapClassicStageChangeHandler = new BeatmapClassicStageChangeHandler()); | ||
AddInternal(stageEditorVerifier = new StageEditorVerifier()); | ||
|
||
Child = new GridContainer | ||
|