mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 16:43:52 +09:00
Merge pull request #21650 from cdwcgt/previewTime
Add ability to set preview time in editor
This commit is contained in:
@ -6,6 +6,7 @@
|
|||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
using osu.Game.Rulesets.Osu;
|
using osu.Game.Rulesets.Osu;
|
||||||
using osu.Game.Screens.Edit;
|
using osu.Game.Screens.Edit;
|
||||||
using osu.Game.Screens.Edit.Components.Timelines.Summary;
|
using osu.Game.Screens.Edit.Components.Timelines.Summary;
|
||||||
@ -21,7 +22,13 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
|
|
||||||
public TestSceneEditorSummaryTimeline()
|
public TestSceneEditorSummaryTimeline()
|
||||||
{
|
{
|
||||||
editorBeatmap = new EditorBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo));
|
var beatmap = CreateBeatmap(new OsuRuleset().RulesetInfo);
|
||||||
|
|
||||||
|
beatmap.ControlPointInfo.Add(100000, new TimingControlPoint { BeatLength = 100 });
|
||||||
|
beatmap.ControlPointInfo.Add(50000, new DifficultyControlPoint { SliderVelocity = 2 });
|
||||||
|
beatmap.BeatmapInfo.Bookmarks = new[] { 75000, 125000 };
|
||||||
|
|
||||||
|
editorBeatmap = new EditorBeatmap(beatmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
|
35
osu.Game.Tests/Visual/Editing/TestScenePreviewTime.cs
Normal file
35
osu.Game.Tests/Visual/Editing/TestScenePreviewTime.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Rulesets;
|
||||||
|
using osu.Game.Rulesets.Osu;
|
||||||
|
using osu.Game.Screens.Edit.Components.Timelines.Summary.Parts;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Editing
|
||||||
|
{
|
||||||
|
public partial class TestScenePreviewTime : EditorTestScene
|
||||||
|
{
|
||||||
|
protected override Ruleset CreateEditorRuleset() => new OsuRuleset();
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSceneSetPreviewTimingPoint()
|
||||||
|
{
|
||||||
|
AddStep("seek to 1000", () => EditorClock.Seek(1000));
|
||||||
|
AddAssert("time is 1000", () => EditorClock.CurrentTime == 1000);
|
||||||
|
AddStep("set current time as preview point", () => Editor.SetPreviewPointToCurrentTime());
|
||||||
|
AddAssert("preview time is 1000", () => EditorBeatmap.PreviewTime.Value == 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestScenePreviewTimeline()
|
||||||
|
{
|
||||||
|
AddStep("set preview time to -1", () => EditorBeatmap.PreviewTime.Value = -1);
|
||||||
|
AddAssert("preview time line should not show", () => !Editor.ChildrenOfType<PreviewTimePart>().Single().Children.Any());
|
||||||
|
AddStep("set preview time to 1000", () => EditorBeatmap.PreviewTime.Value = 1000);
|
||||||
|
AddAssert("preview time line should show", () => Editor.ChildrenOfType<PreviewTimePart>().Single().Children.Single().Alpha == 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Screens.Edit.Components.Timelines.Summary.Visualisations;
|
||||||
|
|
||||||
|
namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
|
||||||
|
{
|
||||||
|
public partial class PreviewTimePart : TimelinePart
|
||||||
|
{
|
||||||
|
private readonly BindableInt previewTime = new BindableInt();
|
||||||
|
|
||||||
|
protected override void LoadBeatmap(EditorBeatmap beatmap)
|
||||||
|
{
|
||||||
|
base.LoadBeatmap(beatmap);
|
||||||
|
|
||||||
|
previewTime.UnbindAll();
|
||||||
|
previewTime.BindTo(beatmap.PreviewTime);
|
||||||
|
previewTime.BindValueChanged(t =>
|
||||||
|
{
|
||||||
|
Clear();
|
||||||
|
|
||||||
|
if (t.NewValue >= 0)
|
||||||
|
Add(new PreviewTimeVisualisation(t.NewValue));
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private partial class PreviewTimeVisualisation : PointVisualisation
|
||||||
|
{
|
||||||
|
public PreviewTimeVisualisation(double time)
|
||||||
|
: base(time)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(OsuColour colours) => Colour = colours.Green1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -41,6 +41,13 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Height = 0.35f
|
Height = 0.35f
|
||||||
},
|
},
|
||||||
|
new PreviewTimePart
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Height = 0.35f
|
||||||
|
},
|
||||||
new Container
|
new Container
|
||||||
{
|
{
|
||||||
Name = "centre line",
|
Name = "centre line",
|
||||||
|
@ -322,6 +322,13 @@ namespace osu.Game.Screens.Edit
|
|||||||
State = { BindTarget = editorHitMarkers },
|
State = { BindTarget = editorHitMarkers },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
new MenuItem("Timing")
|
||||||
|
{
|
||||||
|
Items = new MenuItem[]
|
||||||
|
{
|
||||||
|
new EditorMenuItem("Set preview point to current time", MenuItemType.Standard, SetPreviewPointToCurrentTime)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -801,6 +808,11 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
protected void Redo() => changeHandler?.RestoreState(1);
|
protected void Redo() => changeHandler?.RestoreState(1);
|
||||||
|
|
||||||
|
protected void SetPreviewPointToCurrentTime()
|
||||||
|
{
|
||||||
|
editorBeatmap.PreviewTime.Value = (int)clock.CurrentTime;
|
||||||
|
}
|
||||||
|
|
||||||
private void resetTrack(bool seekToStart = false)
|
private void resetTrack(bool seekToStart = false)
|
||||||
{
|
{
|
||||||
Beatmap.Value.Track.Stop();
|
Beatmap.Value.Track.Stop();
|
||||||
|
@ -86,6 +86,8 @@ namespace osu.Game.Screens.Edit
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private EditorClock editorClock { get; set; }
|
private EditorClock editorClock { get; set; }
|
||||||
|
|
||||||
|
public BindableInt PreviewTime { get; }
|
||||||
|
|
||||||
private readonly IBeatmapProcessor beatmapProcessor;
|
private readonly IBeatmapProcessor beatmapProcessor;
|
||||||
|
|
||||||
private readonly Dictionary<HitObject, Bindable<double>> startTimeBindables = new Dictionary<HitObject, Bindable<double>>();
|
private readonly Dictionary<HitObject, Bindable<double>> startTimeBindables = new Dictionary<HitObject, Bindable<double>>();
|
||||||
@ -107,6 +109,14 @@ namespace osu.Game.Screens.Edit
|
|||||||
|
|
||||||
foreach (var obj in HitObjects)
|
foreach (var obj in HitObjects)
|
||||||
trackStartTime(obj);
|
trackStartTime(obj);
|
||||||
|
|
||||||
|
PreviewTime = new BindableInt(BeatmapInfo.Metadata.PreviewTime);
|
||||||
|
PreviewTime.BindValueChanged(s =>
|
||||||
|
{
|
||||||
|
BeginChange();
|
||||||
|
BeatmapInfo.Metadata.PreviewTime = s.NewValue;
|
||||||
|
EndChange();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -102,6 +102,8 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
public new void Redo() => base.Redo();
|
public new void Redo() => base.Redo();
|
||||||
|
|
||||||
|
public new void SetPreviewPointToCurrentTime() => base.SetPreviewPointToCurrentTime();
|
||||||
|
|
||||||
public new bool Save() => base.Save();
|
public new bool Save() => base.Save();
|
||||||
|
|
||||||
public new void Cut() => base.Cut();
|
public new void Cut() => base.Cut();
|
||||||
|
Reference in New Issue
Block a user