Merge pull request #1314 from peppy/fix-invisible-marker

Editor timeline fixes
This commit is contained in:
Dan Balasescu 2017-09-27 15:09:33 +09:00 committed by GitHub
commit 415b0b299c
5 changed files with 25 additions and 9 deletions

View File

@ -15,6 +15,7 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
{ {
protected override void LoadBeatmap(WorkingBeatmap beatmap) protected override void LoadBeatmap(WorkingBeatmap beatmap)
{ {
base.LoadBeatmap(beatmap);
foreach (int bookmark in beatmap.BeatmapInfo.Bookmarks) foreach (int bookmark in beatmap.BeatmapInfo.Bookmarks)
Add(new BookmarkVisualisation(bookmark)); Add(new BookmarkVisualisation(bookmark));
} }

View File

@ -16,6 +16,7 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
{ {
protected override void LoadBeatmap(WorkingBeatmap beatmap) protected override void LoadBeatmap(WorkingBeatmap beatmap)
{ {
base.LoadBeatmap(beatmap);
foreach (var breakPeriod in beatmap.Beatmap.Breaks) foreach (var breakPeriod in beatmap.Beatmap.Breaks)
Add(new BreakVisualisation(breakPeriod)); Add(new BreakVisualisation(breakPeriod));
} }

View File

@ -18,6 +18,8 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
{ {
protected override void LoadBeatmap(WorkingBeatmap beatmap) protected override void LoadBeatmap(WorkingBeatmap beatmap)
{ {
base.LoadBeatmap(beatmap);
ControlPointInfo cpi = beatmap.Beatmap.ControlPointInfo; ControlPointInfo cpi = beatmap.Beatmap.ControlPointInfo;
cpi.TimingPoints.ForEach(addTimingPoint); cpi.TimingPoints.ForEach(addTimingPoint);

View File

@ -7,6 +7,7 @@ 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; using osu.Framework.Input;
using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
@ -23,12 +24,6 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
Add(marker = new MarkerVisualisation()); Add(marker = new MarkerVisualisation());
} }
[BackgroundDependencyLoader]
private void load(OsuColour colours)
{
marker.Colour = colours.Red;
}
protected override bool OnDragStart(InputState state) => true; protected override bool OnDragStart(InputState state) => true;
protected override bool OnDragEnd(InputState state) => true; protected override bool OnDragEnd(InputState state) => true;
protected override bool OnDrag(InputState state) protected override bool OnDrag(InputState state)
@ -61,10 +56,14 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
protected override void Update() protected override void Update()
{ {
base.Update(); base.Update();
marker.X = (float)(Beatmap.Value?.Track.CurrentTime ?? 0); marker.X = (float)(Beatmap.Value?.Track.CurrentTime ?? 0);
} }
protected override void LoadBeatmap(WorkingBeatmap beatmap)
{
// block base call so we don't clear our marker (can be reused on beatmap change).
}
private class MarkerVisualisation : CompositeDrawable private class MarkerVisualisation : CompositeDrawable
{ {
public MarkerVisualisation() public MarkerVisualisation()

View File

@ -25,16 +25,29 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
Beatmap.ValueChanged += b => Beatmap.ValueChanged += b =>
{ {
timeline.Clear(); updateRelativeChildSize();
timeline.RelativeChildSize = new Vector2((float)Math.Max(1, b.Track.Length), 1);
LoadBeatmap(b); LoadBeatmap(b);
}; };
} }
private void updateRelativeChildSize()
{
// the track may not be loaded completely (only has a length once it is).
if (!Beatmap.Value.Track.IsLoaded)
{
timeline.RelativeChildSize = Vector2.One;
Schedule(updateRelativeChildSize);
return;
}
timeline.RelativeChildSize = new Vector2((float)Math.Max(1, Beatmap.Value.Track.Length), 1);
}
protected void Add(Drawable visualisation) => timeline.Add(visualisation); protected void Add(Drawable visualisation) => timeline.Add(visualisation);
protected virtual void LoadBeatmap(WorkingBeatmap beatmap) protected virtual void LoadBeatmap(WorkingBeatmap beatmap)
{ {
timeline.Clear();
} }
} }
} }