mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 22:56:36 +09:00
Add scrolling algorithm to global settings
This commit is contained in:
@ -16,7 +16,7 @@ namespace osu.Game.Rulesets.UI
|
||||
/// <summary>
|
||||
/// The HitObjects contained in this Playfield.
|
||||
/// </summary>
|
||||
public readonly HitObjectContainer HitObjects;
|
||||
public HitObjectContainer HitObjects { get; private set; }
|
||||
|
||||
public Container<Drawable> 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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,17 +0,0 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// 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);
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// 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);
|
||||
}
|
||||
}
|
@ -1,17 +1,19 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// 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<ScrollingAlgorithmType>(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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the algorithm that will process the positions of the <see cref="DrawableHitObject"/>s.
|
||||
/// </summary>
|
||||
protected abstract IScrollingAlgorithm CreateScrollingAlgorithm();
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
||||
/// <summary>
|
||||
/// Creates the <see cref="ScrollingHitObjectContainer"/> that will handle the scrolling of the <see cref="DrawableHitObject"/>s.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected virtual ScrollingHitObjectContainer CreateScrollingHitObjectContainer() => new GlobalScrollingHitObjectContainer(direction);
|
||||
protected sealed override HitObjectContainer CreateHitObjectContainer() => new ScrollingHitObjectContainer(direction);
|
||||
|
||||
private class TransformVisibleTimeRange : Transform<double, ScrollingPlayfield>
|
||||
{
|
||||
|
Reference in New Issue
Block a user