1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-27 00:23:01 +08:00

Add scrolling algorithm to global settings

This commit is contained in:
smoogipoo 2018-01-08 11:34:37 +09:00
parent 4ab3b0d76b
commit c4d1922c8b
11 changed files with 77 additions and 61 deletions

View File

@ -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
}
}

View File

@ -0,0 +1,15 @@
// 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 System.ComponentModel;
namespace osu.Game.Configuration
{
public enum ScrollingAlgorithmType
{
[Description("Global")]
Global,
[Description("Local")]
Local
}
}

View File

@ -0,0 +1,26 @@
// 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.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<ScrollingAlgorithmType>
{
LabelText = "Scrolling algorithm",
Bindable = config.GetBindable<ScrollingAlgorithmType>(OsuSetting.ScrollingAlgorithm),
}
};
}
}
}

View File

@ -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
}
}
}
}
}

View File

@ -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);
}

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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();
}
}

View File

@ -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>
{

View File

@ -265,6 +265,7 @@
<Compile Include="Beatmaps\Formats\JsonBeatmapDecoder.cs" />
<Compile Include="Beatmaps\Formats\LegacyDecoder.cs" />
<Compile Include="Beatmaps\Formats\LegacyStoryboardDecoder.cs" />
<Compile Include="Configuration\ScrollingAlgorithmType.cs" />
<Compile Include="Database\DatabaseContextFactory.cs" />
<Compile Include="Database\IHasPrimaryKey.cs" />
<Compile Include="Graphics\Textures\LargeTextureStore.cs" />
@ -310,6 +311,7 @@
<Compile Include="Overlays\Profile\Sections\Ranks\PaginatedScoreContainer.cs" />
<Compile Include="Overlays\Profile\Sections\Ranks\DrawableTotalScore.cs" />
<Compile Include="Overlays\Profile\Sections\Ranks\ScoreModsContainer.cs" />
<Compile Include="Overlays\Settings\Sections\Gameplay\ScrollingSettings.cs" />
<Compile Include="Overlays\Settings\Sections\Maintenance\DeleteAllBeatmapsDialog.cs" />
<Compile Include="Rulesets\Mods\IApplicableFailOverride.cs" />
<Compile Include="Rulesets\Mods\IApplicableMod.cs" />
@ -319,8 +321,6 @@
<Compile Include="Rulesets\UI\Scrolling\Algorithms\GlobalScrollingAlgorithm.cs" />
<Compile Include="Rulesets\UI\Scrolling\Algorithms\IScrollingAlgorithm.cs" />
<Compile Include="Rulesets\UI\Scrolling\Algorithms\LocalScrollingAlgorithm.cs" />
<Compile Include="Rulesets\UI\Scrolling\GlobalScrollingHitObjectContainer.cs" />
<Compile Include="Rulesets\UI\Scrolling\LocalScrollingHitObjectContainer.cs" />
<Compile Include="Rulesets\UI\Scrolling\ScrollingDirection.cs" />
<Compile Include="Rulesets\UI\Scrolling\ScrollingHitObjectContainer.cs" />
<Compile Include="Rulesets\UI\Scrolling\ScrollingPlayfield.cs" />