mirror of
https://github.com/osukey/osukey.git
synced 2025-08-02 22:26:41 +09:00
Merge remote-tracking branch 'origin/master' into playfield-scaling-rework
# Conflicts: # osu.Game.Rulesets.Catch/UI/CatchPlayfield.cs # osu.Game/Rulesets/UI/Scrolling/ScrollingPlayfield.cs
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
// Copyright (c) 2007-2018 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;
|
||||
@ -33,20 +32,16 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
||||
|
||||
private Cached initialStateCache = new Cached();
|
||||
|
||||
public ScrollingHitObjectContainer()
|
||||
private readonly ISpeedChangeVisualiser speedChangeVisualiser;
|
||||
|
||||
public ScrollingHitObjectContainer(SpeedChangeVisualisationMethod visualisationMethod)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
TimeRange.ValueChanged += _ => initialStateCache.Invalidate();
|
||||
Direction.ValueChanged += _ => initialStateCache.Invalidate();
|
||||
}
|
||||
|
||||
private ISpeedChangeVisualiser speedChangeVisualiser;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuConfigManager config)
|
||||
{
|
||||
switch (config.Get<SpeedChangeVisualisationMethod>(OsuSetting.SpeedChangeVisualisation))
|
||||
switch (visualisationMethod)
|
||||
{
|
||||
case SpeedChangeVisualisationMethod.Sequential:
|
||||
speedChangeVisualiser = new SequentialSpeedChangeVisualiser(ControlPoints);
|
||||
@ -54,6 +49,9 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
||||
case SpeedChangeVisualisationMethod.Overlapping:
|
||||
speedChangeVisualiser = new OverlappingSpeedChangeVisualiser(ControlPoints);
|
||||
break;
|
||||
case SpeedChangeVisualisationMethod.Constant:
|
||||
speedChangeVisualiser = new ConstantSpeedChangeVisualiser();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ 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;
|
||||
|
||||
@ -62,6 +63,8 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
||||
/// </summary>
|
||||
protected readonly Bindable<ScrollingDirection> Direction = new Bindable<ScrollingDirection>();
|
||||
|
||||
protected virtual SpeedChangeVisualisationMethod VisualisationMethod => SpeedChangeVisualisationMethod.Sequential;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
@ -90,7 +93,7 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
||||
|
||||
protected sealed override HitObjectContainer CreateHitObjectContainer()
|
||||
{
|
||||
var container = new ScrollingHitObjectContainer();
|
||||
var container = new ScrollingHitObjectContainer(VisualisationMethod);
|
||||
container.Direction.BindTo(Direction);
|
||||
return container;
|
||||
}
|
||||
|
@ -0,0 +1,67 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Rulesets.UI.Scrolling.Visualisers
|
||||
{
|
||||
public class ConstantSpeedChangeVisualiser : ISpeedChangeVisualiser
|
||||
{
|
||||
public void ComputeInitialStates(IEnumerable<DrawableHitObject> hitObjects, ScrollingDirection direction, double timeRange, Vector2 length)
|
||||
{
|
||||
foreach (var obj in hitObjects)
|
||||
{
|
||||
obj.LifetimeStart = obj.HitObject.StartTime - timeRange;
|
||||
|
||||
if (obj.HitObject is IHasEndTime endTime)
|
||||
{
|
||||
var hitObjectLength = (endTime.EndTime - obj.HitObject.StartTime) / timeRange;
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
case ScrollingDirection.Up:
|
||||
case ScrollingDirection.Down:
|
||||
obj.Height = (float)(hitObjectLength * length.Y);
|
||||
break;
|
||||
case ScrollingDirection.Left:
|
||||
case ScrollingDirection.Right:
|
||||
obj.Width = (float)(hitObjectLength * length.X);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ComputeInitialStates(obj.NestedHitObjects, direction, timeRange, length);
|
||||
|
||||
// Nested hitobjects don't need to scroll, but they do need accurate positions
|
||||
UpdatePositions(obj.NestedHitObjects, direction, obj.HitObject.StartTime, timeRange, length);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdatePositions(IEnumerable<DrawableHitObject> hitObjects, ScrollingDirection direction, double currentTime, double timeRange, Vector2 length)
|
||||
{
|
||||
foreach (var obj in hitObjects)
|
||||
{
|
||||
var position = (obj.HitObject.StartTime - currentTime) / timeRange;
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
case ScrollingDirection.Up:
|
||||
obj.Y = (float)(position * length.Y);
|
||||
break;
|
||||
case ScrollingDirection.Down:
|
||||
obj.Y = (float)(-position * length.Y);
|
||||
break;
|
||||
case ScrollingDirection.Left:
|
||||
obj.X = (float)(position * length.X);
|
||||
break;
|
||||
case ScrollingDirection.Right:
|
||||
obj.X = (float)(-position * length.X);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user