1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-16 01:42:58 +08:00

Merge pull request #11596 from peppy/fix-timeline-parts-working-beatmap

This commit is contained in:
Bartłomiej Dach 2021-01-25 18:36:34 +01:00 committed by GitHub
commit 4c01cf6664
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 25 additions and 24 deletions

View File

@ -5,6 +5,8 @@ using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Rulesets.Osu; using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Beatmaps;
using osu.Game.Screens.Edit;
using osu.Game.Screens.Edit.Components.Timelines.Summary; using osu.Game.Screens.Edit.Components.Timelines.Summary;
using osuTK; using osuTK;
@ -13,6 +15,9 @@ namespace osu.Game.Tests.Visual.Editing
[TestFixture] [TestFixture]
public class TestSceneEditorSummaryTimeline : EditorClockTestScene public class TestSceneEditorSummaryTimeline : EditorClockTestScene
{ {
[Cached(typeof(EditorBeatmap))]
private readonly EditorBeatmap editorBeatmap = new EditorBeatmap(new OsuBeatmap());
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Screens.Edit.Components.Timelines.Summary.Visualisations; using osu.Game.Screens.Edit.Components.Timelines.Summary.Visualisations;
@ -13,7 +12,7 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
/// </summary> /// </summary>
public class BookmarkPart : TimelinePart public class BookmarkPart : TimelinePart
{ {
protected override void LoadBeatmap(WorkingBeatmap beatmap) protected override void LoadBeatmap(EditorBeatmap beatmap)
{ {
base.LoadBeatmap(beatmap); base.LoadBeatmap(beatmap);
foreach (int bookmark in beatmap.BeatmapInfo.Bookmarks) foreach (int bookmark in beatmap.BeatmapInfo.Bookmarks)

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Timing; using osu.Game.Beatmaps.Timing;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Screens.Edit.Components.Timelines.Summary.Visualisations; using osu.Game.Screens.Edit.Components.Timelines.Summary.Visualisations;
@ -14,10 +13,10 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
/// </summary> /// </summary>
public class BreakPart : TimelinePart public class BreakPart : TimelinePart
{ {
protected override void LoadBeatmap(WorkingBeatmap beatmap) protected override void LoadBeatmap(EditorBeatmap beatmap)
{ {
base.LoadBeatmap(beatmap); base.LoadBeatmap(beatmap);
foreach (var breakPeriod in beatmap.Beatmap.Breaks) foreach (var breakPeriod in beatmap.Breaks)
Add(new BreakVisualisation(breakPeriod)); Add(new BreakVisualisation(breakPeriod));
} }

View File

@ -4,7 +4,6 @@
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Linq; using System.Linq;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
@ -16,12 +15,12 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
{ {
private readonly IBindableList<ControlPointGroup> controlPointGroups = new BindableList<ControlPointGroup>(); private readonly IBindableList<ControlPointGroup> controlPointGroups = new BindableList<ControlPointGroup>();
protected override void LoadBeatmap(WorkingBeatmap beatmap) protected override void LoadBeatmap(EditorBeatmap beatmap)
{ {
base.LoadBeatmap(beatmap); base.LoadBeatmap(beatmap);
controlPointGroups.UnbindAll(); controlPointGroups.UnbindAll();
controlPointGroups.BindTo(beatmap.Beatmap.ControlPointInfo.Groups); controlPointGroups.BindTo(beatmap.ControlPointInfo.Groups);
controlPointGroups.BindCollectionChanged((sender, args) => controlPointGroups.BindCollectionChanged((sender, args) =>
{ {
switch (args.Action) switch (args.Action)

View File

@ -2,15 +2,14 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System; using System;
using osuTK;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Framework.Threading; using osu.Framework.Threading;
using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
using osuTK;
namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
{ {
@ -54,9 +53,6 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
scheduledSeek?.Cancel(); scheduledSeek?.Cancel();
scheduledSeek = Schedule(() => scheduledSeek = Schedule(() =>
{ {
if (Beatmap.Value == null)
return;
float markerPos = Math.Clamp(ToLocalSpace(screenPosition).X, 0, DrawWidth); float markerPos = Math.Clamp(ToLocalSpace(screenPosition).X, 0, DrawWidth);
editorClock.SeekSmoothlyTo(markerPos / DrawWidth * editorClock.TrackLength); editorClock.SeekSmoothlyTo(markerPos / DrawWidth * editorClock.TrackLength);
}); });
@ -68,7 +64,7 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
marker.X = (float)editorClock.CurrentTime; marker.X = (float)editorClock.CurrentTime;
} }
protected override void LoadBeatmap(WorkingBeatmap beatmap) protected override void LoadBeatmap(EditorBeatmap beatmap)
{ {
// block base call so we don't clear our marker (can be reused on beatmap change). // block base call so we don't clear our marker (can be reused on beatmap change).
} }

View File

@ -21,7 +21,10 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
/// </summary> /// </summary>
public class TimelinePart<T> : Container<T> where T : Drawable public class TimelinePart<T> : Container<T> where T : Drawable
{ {
protected readonly IBindable<WorkingBeatmap> Beatmap = new Bindable<WorkingBeatmap>(); private readonly IBindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
[Resolved]
protected EditorBeatmap EditorBeatmap { get; private set; }
protected readonly IBindable<Track> Track = new Bindable<Track>(); protected readonly IBindable<Track> Track = new Bindable<Track>();
@ -33,10 +36,9 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
{ {
AddInternal(this.content = content ?? new Container<T> { RelativeSizeAxes = Axes.Both }); AddInternal(this.content = content ?? new Container<T> { RelativeSizeAxes = Axes.Both });
Beatmap.ValueChanged += b => beatmap.ValueChanged += b =>
{ {
updateRelativeChildSize(); updateRelativeChildSize();
LoadBeatmap(b.NewValue);
}; };
Track.ValueChanged += _ => updateRelativeChildSize(); Track.ValueChanged += _ => updateRelativeChildSize();
@ -45,24 +47,26 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(IBindable<WorkingBeatmap> beatmap, EditorClock clock) private void load(IBindable<WorkingBeatmap> beatmap, EditorClock clock)
{ {
Beatmap.BindTo(beatmap); this.beatmap.BindTo(beatmap);
LoadBeatmap(EditorBeatmap);
Track.BindTo(clock.Track); Track.BindTo(clock.Track);
} }
private void updateRelativeChildSize() private void updateRelativeChildSize()
{ {
// the track may not be loaded completely (only has a length once it is). // the track may not be loaded completely (only has a length once it is).
if (!Beatmap.Value.Track.IsLoaded) if (!beatmap.Value.Track.IsLoaded)
{ {
content.RelativeChildSize = Vector2.One; content.RelativeChildSize = Vector2.One;
Schedule(updateRelativeChildSize); Schedule(updateRelativeChildSize);
return; return;
} }
content.RelativeChildSize = new Vector2((float)Math.Max(1, Beatmap.Value.Track.Length), 1); content.RelativeChildSize = new Vector2((float)Math.Max(1, beatmap.Value.Track.Length), 1);
} }
protected virtual void LoadBeatmap(WorkingBeatmap beatmap) protected virtual void LoadBeatmap(EditorBeatmap beatmap)
{ {
content.Clear(); content.Clear();
} }

View File

@ -5,7 +5,6 @@ using System.Collections.Specialized;
using System.Linq; using System.Linq;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints; using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Screens.Edit.Components.Timelines.Summary.Parts; using osu.Game.Screens.Edit.Components.Timelines.Summary.Parts;
@ -23,12 +22,12 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
RelativeSizeAxes = Axes.Both; RelativeSizeAxes = Axes.Both;
} }
protected override void LoadBeatmap(WorkingBeatmap beatmap) protected override void LoadBeatmap(EditorBeatmap beatmap)
{ {
base.LoadBeatmap(beatmap); base.LoadBeatmap(beatmap);
controlPointGroups.UnbindAll(); controlPointGroups.UnbindAll();
controlPointGroups.BindTo(beatmap.Beatmap.ControlPointInfo.Groups); controlPointGroups.BindTo(beatmap.ControlPointInfo.Groups);
controlPointGroups.BindCollectionChanged((sender, args) => controlPointGroups.BindCollectionChanged((sender, args) =>
{ {
switch (args.Action) switch (args.Action)