mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 01:09:57 +09:00
Add basic hitobject display to timeline
This commit is contained in:
@ -0,0 +1,85 @@
|
||||
// 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 osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Screens.Edit.Components.Timelines.Summary.Parts;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
{
|
||||
internal class TimelineHitObjectDisplay : TimelinePart
|
||||
{
|
||||
[Resolved]
|
||||
private IEditorBeatmap beatmap { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
foreach (var h in beatmap.HitObjects)
|
||||
add(h);
|
||||
|
||||
beatmap.HitObjectAdded += add;
|
||||
beatmap.HitObjectRemoved += remove;
|
||||
}
|
||||
|
||||
private void remove(HitObject h)
|
||||
{
|
||||
foreach (var d in InternalChildren.OfType<TimelineHitObjectRepresentation>().Where(c => c.HitObject == h))
|
||||
d.Expire();
|
||||
}
|
||||
|
||||
private void add(HitObject h)
|
||||
{
|
||||
Add(new TimelineHitObjectRepresentation(h));
|
||||
}
|
||||
|
||||
private class TimelineHitObjectRepresentation : CompositeDrawable
|
||||
{
|
||||
public readonly HitObject HitObject;
|
||||
|
||||
public TimelineHitObjectRepresentation(HitObject hitObject)
|
||||
{
|
||||
this.HitObject = hitObject;
|
||||
Anchor = Anchor.CentreLeft;
|
||||
Origin = Anchor.CentreLeft;
|
||||
|
||||
Width = (float)(hitObject.GetEndTime() - hitObject.StartTime);
|
||||
|
||||
X = (float)hitObject.StartTime;
|
||||
|
||||
RelativePositionAxes = Axes.X;
|
||||
RelativeSizeAxes = Axes.X;
|
||||
|
||||
AddInternal(new Circle
|
||||
{
|
||||
Size = new Vector2(16),
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.Centre,
|
||||
RelativePositionAxes = Axes.X,
|
||||
AlwaysPresent = true,
|
||||
Colour = Color4.White,
|
||||
});
|
||||
|
||||
if (hitObject is IHasEndTime)
|
||||
{
|
||||
AddInternal(new Box
|
||||
{
|
||||
Size = new Vector2(1, 5),
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
RelativePositionAxes = Axes.X,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Colour = Color4.White,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user