// Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using OpenTK; namespace osu.Game.Rulesets.Taiko.Objects.Drawables { /// /// A line that scrolls alongside hit objects in the playfield and visualises control points. /// public class DrawableBarLine : Container { /// /// The width of the line tracker. /// private const float tracker_width = 2f; /// /// Fade out time calibrated to a pre-empt of 1000ms. /// private const float base_fadeout_time = 100f; /// /// The visual line tracker. /// protected Box Tracker; /// /// The bar line. /// protected readonly BarLine BarLine; public DrawableBarLine(BarLine barLine) { BarLine = barLine; Anchor = Anchor.CentreLeft; Origin = Anchor.Centre; RelativePositionAxes = Axes.X; RelativeSizeAxes = Axes.Y; Width = tracker_width; Children = new[] { Tracker = new Box { Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.Both, EdgeSmoothness = new Vector2(0.5f, 0), Alpha = 0.75f } }; LifetimeStart = BarLine.StartTime - BarLine.ScrollTime * 2; LifetimeEnd = BarLine.StartTime + BarLine.ScrollTime; } protected override void LoadComplete() { base.LoadComplete(); this.Delay(BarLine.StartTime - Time.Current).FadeOut(base_fadeout_time * BarLine.ScrollTime / 1000); } private void updateScrollPosition(double time) => this.MoveToX((float)((BarLine.StartTime - time) / BarLine.ScrollTime)); protected override void Update() { base.Update(); updateScrollPosition(Time.Current); } } }