diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index f4c7bdb586..4ff4105b77 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -71,6 +71,8 @@ namespace osu.Game.Configuration Set(OsuSetting.FloatingComments, false); + Set(OsuSetting.ScrollingAlgorithm, ScrollingAlgorithmType.Global); + // Update Set(OsuSetting.ReleaseStream, ReleaseStream.Lazer); @@ -114,6 +116,7 @@ namespace osu.Game.Configuration ShowFpsDisplay, ChatDisplayHeight, Version, - ShowConvertedBeatmaps + ShowConvertedBeatmaps, + ScrollingAlgorithm } } diff --git a/osu.Game/Configuration/ScrollingAlgorithmType.cs b/osu.Game/Configuration/ScrollingAlgorithmType.cs new file mode 100644 index 0000000000..b4a2b8a4a3 --- /dev/null +++ b/osu.Game/Configuration/ScrollingAlgorithmType.cs @@ -0,0 +1,15 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE + +using System.ComponentModel; + +namespace osu.Game.Configuration +{ + public enum ScrollingAlgorithmType + { + [Description("Global")] + Global, + [Description("Local")] + Local + } +} diff --git a/osu.Game/Overlays/Settings/Sections/Gameplay/ScrollingSettings.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/ScrollingSettings.cs new file mode 100644 index 0000000000..b2a2a25da7 --- /dev/null +++ b/osu.Game/Overlays/Settings/Sections/Gameplay/ScrollingSettings.cs @@ -0,0 +1,26 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE + +using osu.Framework.Allocation; +using osu.Game.Configuration; + +namespace osu.Game.Overlays.Settings.Sections.Gameplay +{ + public class ScrollingSettings : SettingsSubsection + { + protected override string Header => "Scrolling"; + + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + Children = new[] + { + new SettingsEnumDropdown + { + LabelText = "Scrolling algorithm", + Bindable = config.GetBindable(OsuSetting.ScrollingAlgorithm), + } + }; + } + } +} diff --git a/osu.Game/Overlays/Settings/Sections/GameplaySection.cs b/osu.Game/Overlays/Settings/Sections/GameplaySection.cs index 035a3c7a13..8b05bfe8de 100644 --- a/osu.Game/Overlays/Settings/Sections/GameplaySection.cs +++ b/osu.Game/Overlays/Settings/Sections/GameplaySection.cs @@ -21,6 +21,7 @@ namespace osu.Game.Overlays.Settings.Sections { new GeneralSettings(), new SongSelectSettings(), + new ScrollingSettings() }; } @@ -35,4 +36,4 @@ namespace osu.Game.Overlays.Settings.Sections } } } -} \ No newline at end of file +} diff --git a/osu.Game/Rulesets/UI/Playfield.cs b/osu.Game/Rulesets/UI/Playfield.cs index 91ea3ade2a..0f8a650718 100644 --- a/osu.Game/Rulesets/UI/Playfield.cs +++ b/osu.Game/Rulesets/UI/Playfield.cs @@ -16,7 +16,7 @@ namespace osu.Game.Rulesets.UI /// /// The HitObjects contained in this Playfield. /// - public readonly HitObjectContainer HitObjects; + public HitObjectContainer HitObjects { get; private set; } public Container ScaledContent; @@ -49,14 +49,14 @@ namespace osu.Game.Rulesets.UI } } }); - - HitObjects = CreateHitObjectContainer(); - HitObjects.RelativeSizeAxes = Axes.Both; } [BackgroundDependencyLoader] private void load() { + HitObjects = CreateHitObjectContainer(); + HitObjects.RelativeSizeAxes = Axes.Both; + Add(HitObjects); } diff --git a/osu.Game/Rulesets/UI/Scrolling/Algorithms/LocalScrollingAlgorithm.cs b/osu.Game/Rulesets/UI/Scrolling/Algorithms/LocalScrollingAlgorithm.cs index ddd06a3725..be8612ca96 100644 --- a/osu.Game/Rulesets/UI/Scrolling/Algorithms/LocalScrollingAlgorithm.cs +++ b/osu.Game/Rulesets/UI/Scrolling/Algorithms/LocalScrollingAlgorithm.cs @@ -28,7 +28,7 @@ namespace osu.Game.Rulesets.UI.Scrolling.Algorithms var controlPoint = controlPointAt(obj.HitObject.StartTime); obj.LifetimeStart = obj.HitObject.StartTime - timeRange / controlPoint.Multiplier; - obj.LifetimeEnd = ((obj as IHasEndTime)?.EndTime ?? obj.HitObject.StartTime) + timeRange / controlPoint.Multiplier; + obj.LifetimeEnd = ((obj.HitObject as IHasEndTime)?.EndTime ?? obj.HitObject.StartTime) + timeRange / controlPoint.Multiplier; } } diff --git a/osu.Game/Rulesets/UI/Scrolling/GlobalScrollingHitObjectContainer.cs b/osu.Game/Rulesets/UI/Scrolling/GlobalScrollingHitObjectContainer.cs deleted file mode 100644 index 23dff01940..0000000000 --- a/osu.Game/Rulesets/UI/Scrolling/GlobalScrollingHitObjectContainer.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE - -using osu.Game.Rulesets.UI.Scrolling.Algorithms; - -namespace osu.Game.Rulesets.UI.Scrolling -{ - public class GlobalScrollingHitObjectContainer : ScrollingHitObjectContainer - { - public GlobalScrollingHitObjectContainer(ScrollingDirection direction) - : base(direction) - { - } - - protected override IScrollingAlgorithm CreateScrollingAlgorithm() => new GlobalScrollingAlgorithm(ControlPoints); - } -} diff --git a/osu.Game/Rulesets/UI/Scrolling/LocalScrollingHitObjectContainer.cs b/osu.Game/Rulesets/UI/Scrolling/LocalScrollingHitObjectContainer.cs deleted file mode 100644 index ceef688cbc..0000000000 --- a/osu.Game/Rulesets/UI/Scrolling/LocalScrollingHitObjectContainer.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2007-2018 ppy Pty Ltd . -// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE - -using osu.Game.Rulesets.UI.Scrolling.Algorithms; - -namespace osu.Game.Rulesets.UI.Scrolling -{ - public class LocalScrollingHitObjectContainer : ScrollingHitObjectContainer - { - public LocalScrollingHitObjectContainer(ScrollingDirection direction) - : base(direction) - { - } - - protected override IScrollingAlgorithm CreateScrollingAlgorithm() => new LocalScrollingAlgorithm(ControlPoints); - } -} diff --git a/osu.Game/Rulesets/UI/Scrolling/ScrollingHitObjectContainer.cs b/osu.Game/Rulesets/UI/Scrolling/ScrollingHitObjectContainer.cs index e1d8fe8d59..67f2e8aee0 100644 --- a/osu.Game/Rulesets/UI/Scrolling/ScrollingHitObjectContainer.cs +++ b/osu.Game/Rulesets/UI/Scrolling/ScrollingHitObjectContainer.cs @@ -1,17 +1,19 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using osu.Framework.Allocation; using osu.Framework.Caching; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Lists; +using osu.Game.Configuration; using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Timing; using osu.Game.Rulesets.UI.Scrolling.Algorithms; namespace osu.Game.Rulesets.UI.Scrolling { - public abstract class ScrollingHitObjectContainer : HitObjectContainer + public class ScrollingHitObjectContainer : HitObjectContainer { public readonly BindableDouble TimeRange = new BindableDouble { @@ -25,7 +27,7 @@ namespace osu.Game.Rulesets.UI.Scrolling private Cached initialStateCache = new Cached(); - protected ScrollingHitObjectContainer(ScrollingDirection direction) + public ScrollingHitObjectContainer(ScrollingDirection direction) { this.direction = direction; @@ -35,11 +37,19 @@ namespace osu.Game.Rulesets.UI.Scrolling } private IScrollingAlgorithm scrollingAlgorithm; - protected override void LoadComplete() - { - base.LoadComplete(); - scrollingAlgorithm = CreateScrollingAlgorithm(); + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + switch (config.Get(OsuSetting.ScrollingAlgorithm)) + { + case ScrollingAlgorithmType.Global: + scrollingAlgorithm = new GlobalScrollingAlgorithm(ControlPoints); + break; + case ScrollingAlgorithmType.Local: + scrollingAlgorithm = new LocalScrollingAlgorithm(ControlPoints); + break; + } } public override void Add(DrawableHitObject hitObject) @@ -99,10 +109,5 @@ namespace osu.Game.Rulesets.UI.Scrolling scrollingAlgorithm.ComputePositions(AliveObjects, direction, Time.Current, TimeRange, DrawSize); } - - /// - /// Creates the algorithm that will process the positions of the s. - /// - protected abstract IScrollingAlgorithm CreateScrollingAlgorithm(); } } diff --git a/osu.Game/Rulesets/UI/Scrolling/ScrollingPlayfield.cs b/osu.Game/Rulesets/UI/Scrolling/ScrollingPlayfield.cs index f560d8eaa6..8669339294 100644 --- a/osu.Game/Rulesets/UI/Scrolling/ScrollingPlayfield.cs +++ b/osu.Game/Rulesets/UI/Scrolling/ScrollingPlayfield.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System.Collections.Generic; +using osu.Framework.Allocation; using osu.Framework.Configuration; using osu.Framework.Graphics; using osu.Framework.Graphics.Transforms; @@ -62,6 +63,11 @@ namespace osu.Game.Rulesets.UI.Scrolling : base(customWidth) { this.direction = direction; + } + + [BackgroundDependencyLoader] + private void load() + { HitObjects.TimeRange.BindTo(VisibleTimeRange); } @@ -107,13 +113,7 @@ namespace osu.Game.Rulesets.UI.Scrolling this.TransformTo(this.PopulateTransform(new TransformVisibleTimeRange(), newTimeRange, duration, easing)); } - protected sealed override HitObjectContainer CreateHitObjectContainer() => CreateScrollingHitObjectContainer(); - - /// - /// Creates the that will handle the scrolling of the s. - /// - /// - protected virtual ScrollingHitObjectContainer CreateScrollingHitObjectContainer() => new GlobalScrollingHitObjectContainer(direction); + protected sealed override HitObjectContainer CreateHitObjectContainer() => new ScrollingHitObjectContainer(direction); private class TransformVisibleTimeRange : Transform { diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 327b87d5de..45183de092 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -265,6 +265,7 @@ + @@ -310,6 +311,7 @@ + @@ -319,8 +321,6 @@ - -