1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 17:52:56 +08:00

Implement proper scrolling directions

This commit is contained in:
smoogipoo 2018-01-04 19:17:40 +09:00
parent f34131f8f4
commit 651e24e3cc
8 changed files with 53 additions and 21 deletions

View File

@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Catch.UI
private readonly CatcherArea catcherArea;
public CatchPlayfield(BeatmapDifficulty difficulty)
: base(Direction.Vertical)
: base(ScrollingDirection.Down)
{
Container explodingFruitContainer;

View File

@ -45,7 +45,7 @@ namespace osu.Game.Rulesets.Mania.UI
private const float opacity_pressed = 0.25f;
public Column()
: base(Direction.Vertical)
: base(ScrollingDirection.Down)
{
Width = column_width;

View File

@ -58,7 +58,7 @@ namespace osu.Game.Rulesets.Mania.UI
private readonly int columnCount;
public ManiaPlayfield(int columnCount)
: base(Direction.Vertical)
: base(ScrollingDirection.Down)
{
this.columnCount = columnCount;

View File

@ -56,7 +56,7 @@ namespace osu.Game.Rulesets.Taiko.UI
private readonly Box background;
public TaikoPlayfield(ControlPointInfo controlPoints)
: base(Direction.Horizontal)
: base(ScrollingDirection.Left)
{
AddRangeInternal(new Drawable[]
{

View File

@ -24,8 +24,8 @@ namespace osu.Game.Tests.Visual
public TestCaseScrollingHitObjects()
{
playfields.Add(new TestPlayfield(Direction.Vertical));
playfields.Add(new TestPlayfield(Direction.Horizontal));
playfields.Add(new TestPlayfield(ScrollingDirection.Down));
playfields.Add(new TestPlayfield(ScrollingDirection.Right));
playfields.ForEach(p => p.HitObjects.ControlPoints.Add(new MultiplierControlPoint(double.MinValue)));
@ -72,7 +72,7 @@ namespace osu.Game.Tests.Visual
{
p.Add(new TestDrawableHitObject(time)
{
Anchor = p.ScrollingDirection == Direction.Horizontal ? Anchor.CentreRight : Anchor.BottomCentre
Anchor = p.Direction == ScrollingDirection.Right ? Anchor.CentreRight : Anchor.BottomCentre
});
});
}
@ -90,7 +90,7 @@ namespace osu.Game.Tests.Visual
TestDrawableControlPoint createDrawablePoint(double t) => new TestDrawableControlPoint(t)
{
Anchor = p.ScrollingDirection == Direction.Horizontal ? Anchor.CentreRight : Anchor.BottomCentre
Anchor = p.Direction == ScrollingDirection.Right ? Anchor.CentreRight : Anchor.BottomCentre
};
p.Add(createDrawablePoint(time));
@ -105,15 +105,15 @@ namespace osu.Game.Tests.Visual
{
public readonly BindableDouble TimeRange = new BindableDouble(5000);
public readonly Direction ScrollingDirection;
public readonly ScrollingDirection Direction;
public new ScrollingPlayfield.ScrollingHitObjectContainer HitObjects => (ScrollingPlayfield.ScrollingHitObjectContainer)base.HitObjects;
public TestPlayfield(Direction scrollingDirection)
public TestPlayfield(ScrollingDirection direction)
{
ScrollingDirection = scrollingDirection;
Direction = direction;
base.HitObjects = new ScrollingPlayfield.ScrollingHitObjectContainer(scrollingDirection);
base.HitObjects = new ScrollingPlayfield.ScrollingHitObjectContainer(direction);
HitObjects.TimeRange.BindTo(TimeRange);
}
}

View File

@ -0,0 +1,25 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE
namespace osu.Game.Rulesets.UI
{
public enum ScrollingDirection
{
/// <summary>
/// Hitobjects will scroll vertically from the bottom of the hitobject container.
/// </summary>
Up,
/// <summary>
/// Hitobjects will scroll vertically from the top of the hitobject container.
/// </summary>
Down,
/// <summary>
/// Hitobjects will scroll horizontally from the right of the hitobject container.
/// </summary>
Left,
/// <summary>
/// Hitobjects will scroll horizontally from the left of the hitobject container.
/// </summary>
Right
}
}

View File

@ -58,10 +58,10 @@ namespace osu.Game.Rulesets.UI
/// </summary>
/// <param name="scrollingAxes">The axes on which <see cref="DrawableHitObject"/>s in this container should scroll.</param>
/// <param name="customWidth">Whether we want our internal coordinate system to be scaled to a specified width</param>
protected ScrollingPlayfield(Direction scrollingDirection, float? customWidth = null)
protected ScrollingPlayfield(ScrollingDirection direction, float? customWidth = null)
: base(customWidth)
{
base.HitObjects = HitObjects = new ScrollingHitObjectContainer(scrollingDirection) { RelativeSizeAxes = Axes.Both };
base.HitObjects = HitObjects = new ScrollingHitObjectContainer(direction) { RelativeSizeAxes = Axes.Both };
HitObjects.TimeRange.BindTo(VisibleTimeRange);
}
@ -133,11 +133,11 @@ namespace osu.Game.Rulesets.UI
public readonly SortedList<MultiplierControlPoint> ControlPoints = new SortedList<MultiplierControlPoint>();
private readonly Direction scrollingDirection;
private readonly ScrollingDirection direction;
public ScrollingHitObjectContainer(Direction scrollingDirection)
public ScrollingHitObjectContainer(ScrollingDirection direction)
{
this.scrollingDirection = scrollingDirection;
this.direction = direction;
RelativeSizeAxes = Axes.Both;
}
@ -155,14 +155,20 @@ namespace osu.Game.Rulesets.UI
// Todo: We may need to consider scale here
var finalPosition = (float)relativePosition * DrawSize;
switch (scrollingDirection)
switch (direction)
{
case Direction.Horizontal:
obj.X = finalPosition.X;
case ScrollingDirection.Up:
obj.Y = -finalPosition.Y;
break;
case Direction.Vertical:
case ScrollingDirection.Down:
obj.Y = finalPosition.Y;
break;
case ScrollingDirection.Left:
obj.X = -finalPosition.X;
break;
case ScrollingDirection.Right:
obj.X = finalPosition.X;
break;
}
}
}

View File

@ -314,6 +314,7 @@
<Compile Include="Rulesets\Mods\IApplicableFailOverride.cs" />
<Compile Include="Rulesets\Mods\IApplicableMod.cs" />
<Compile Include="Rulesets\Mods\IApplicableToDrawableHitObject.cs" />
<Compile Include="Rulesets\UI\ScrollingDirection.cs" />
<Compile Include="Screens\Select\ImportFromStablePopup.cs" />
<Compile Include="Overlays\Settings\SettingsButton.cs" />
<Compile Include="Rulesets\Edit\Layers\Selection\OriginHandle.cs" />