mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 07:06:35 +09:00
Bind to the screen Beatmap instead of the game-wide Beatmap
This commit is contained in:
@ -7,7 +7,6 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
|
||||
@ -17,8 +16,6 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
|
||||
/// </summary>
|
||||
internal class MarkerPart : TimelinePart
|
||||
{
|
||||
private WorkingBeatmap beatmap;
|
||||
|
||||
private readonly Drawable marker;
|
||||
|
||||
public MarkerPart()
|
||||
@ -32,11 +29,6 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
|
||||
marker.Colour = colours.Red;
|
||||
}
|
||||
|
||||
protected override void LoadBeatmap(WorkingBeatmap beatmap)
|
||||
{
|
||||
this.beatmap = beatmap;
|
||||
}
|
||||
|
||||
protected override bool OnDragStart(InputState state) => true;
|
||||
protected override bool OnDragEnd(InputState state) => true;
|
||||
protected override bool OnDrag(InputState state)
|
||||
@ -57,16 +49,22 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
|
||||
/// <param name="screenPosition">The position in screen coordinates.</param>
|
||||
private void seekToPosition(Vector2 screenPosition)
|
||||
{
|
||||
if (Beatmap.Value == null)
|
||||
return;
|
||||
|
||||
float markerPos = MathHelper.Clamp(ToLocalSpace(screenPosition).X, 0, DrawWidth);
|
||||
seekTo(markerPos / DrawWidth * beatmap.Track.Length);
|
||||
seekTo(markerPos / DrawWidth * Beatmap.Value.Track.Length);
|
||||
}
|
||||
|
||||
private void seekTo(double time) => beatmap.Track.Seek(time);
|
||||
private void seekTo(double time) => Beatmap.Value?.Track.Seek(time);
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
marker.X = (float)beatmap.Track.CurrentTime;
|
||||
|
||||
if (Beatmap.Value == null)
|
||||
return;
|
||||
marker.X = (float)Beatmap.Value.Track.CurrentTime;
|
||||
}
|
||||
|
||||
private class MarkerVisualisation : CompositeDrawable
|
||||
@ -80,27 +78,27 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
|
||||
AutoSizeAxes = Axes.X;
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new Triangle
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Scale = new Vector2(1, -1),
|
||||
Size = new Vector2(10, 5),
|
||||
},
|
||||
new Triangle
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Size = new Vector2(10, 5)
|
||||
},
|
||||
new Box
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 2,
|
||||
EdgeSmoothness = new Vector2(1, 0)
|
||||
}
|
||||
new Triangle
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Scale = new Vector2(1, -1),
|
||||
Size = new Vector2(10, 5),
|
||||
},
|
||||
new Triangle
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Size = new Vector2(10, 5)
|
||||
},
|
||||
new Box
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Width = 2,
|
||||
EdgeSmoothness = new Vector2(1, 0)
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
using System;
|
||||
using OpenTK;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Beatmaps;
|
||||
@ -15,29 +15,26 @@ namespace osu.Game.Screens.Edit.Components.Timelines.Summary.Parts
|
||||
/// </summary>
|
||||
internal abstract class TimelinePart : CompositeDrawable
|
||||
{
|
||||
public Bindable<WorkingBeatmap> Beatmap = new Bindable<WorkingBeatmap>();
|
||||
|
||||
private readonly Container timeline;
|
||||
|
||||
protected TimelinePart()
|
||||
{
|
||||
AddInternal(timeline = new Container { RelativeSizeAxes = Axes.Both });
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuGameBase osuGame)
|
||||
{
|
||||
osuGame.Beatmap.ValueChanged += b =>
|
||||
Beatmap.ValueChanged += b =>
|
||||
{
|
||||
timeline.Clear();
|
||||
timeline.RelativeChildSize = new Vector2((float)Math.Max(1, b.Track.Length), 1);
|
||||
LoadBeatmap(b);
|
||||
};
|
||||
|
||||
timeline.RelativeChildSize = new Vector2((float)Math.Max(1, osuGame.Beatmap.Value.Track.Length), 1);
|
||||
LoadBeatmap(osuGame.Beatmap);
|
||||
}
|
||||
|
||||
protected void Add(Drawable visualisation) => timeline.Add(visualisation);
|
||||
|
||||
protected abstract void LoadBeatmap(WorkingBeatmap beatmap);
|
||||
protected virtual void LoadBeatmap(WorkingBeatmap beatmap)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user