// Copyright (c) 2007-2018 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Input.Bindings; using osu.Game.Configuration; using osu.Game.Input.Bindings; using osu.Game.Rulesets.Objects.Drawables; namespace osu.Game.Rulesets.UI.Scrolling { /// /// A type of specialized towards scrolling s. /// public abstract class ScrollingPlayfield : Playfield, IKeyBindingHandler { /// /// The default span of time visible by the length of the scrolling axes. /// This is clamped between and . /// private const double time_span_default = 1500; /// /// The minimum span of time that may be visible by the length of the scrolling axes. /// private const double time_span_min = 50; /// /// The maximum span of time that may be visible by the length of the scrolling axes. /// private const double time_span_max = 10000; /// /// The step increase/decrease of the span of time visible by the length of the scrolling axes. /// private const double time_span_step = 200; /// /// The span of time that is visible by the length of the scrolling axes. /// For example, only hit objects with start time less than or equal to 1000 will be visible with = 1000. /// public readonly BindableDouble VisibleTimeRange = new BindableDouble(time_span_default) { Default = time_span_default, MinValue = time_span_min, MaxValue = time_span_max }; /// /// Whether the player can change . /// protected virtual bool UserScrollSpeedAdjustment => true; /// /// The container that contains the s. /// public new ScrollingHitObjectContainer HitObjects => (ScrollingHitObjectContainer)HitObjectContainer; /// /// The direction in which s in this should scroll. /// protected readonly Bindable Direction = new Bindable(); protected virtual SpeedChangeVisualisationMethod VisualisationMethod => SpeedChangeVisualisationMethod.Sequential; /// /// Creates a new . /// /// The width to scale the internal coordinate space to. /// May be null if scaling based on is desired. If is also null, no scaling will occur. /// /// The height to scale the internal coordinate space to. /// May be null if scaling based on is desired. If is also null, no scaling will occur. /// protected ScrollingPlayfield(float? customWidth = null, float? customHeight = null) : base(customWidth, customHeight) { } [BackgroundDependencyLoader] private void load() { HitObjects.TimeRange.BindTo(VisibleTimeRange); } public bool OnPressed(GlobalAction action) { if (!UserScrollSpeedAdjustment) return false; switch (action) { case GlobalAction.IncreaseScrollSpeed: this.TransformBindableTo(VisibleTimeRange, VisibleTimeRange - time_span_step, 200, Easing.OutQuint); return true; case GlobalAction.DecreaseScrollSpeed: this.TransformBindableTo(VisibleTimeRange, VisibleTimeRange + time_span_step, 200, Easing.OutQuint); return true; } return false; } public bool OnReleased(GlobalAction action) => false; protected sealed override HitObjectContainer CreateHitObjectContainer() { var container = new ScrollingHitObjectContainer(VisualisationMethod); container.Direction.BindTo(Direction); return container; } } }