mirror of
https://github.com/osukey/osukey.git
synced 2025-05-09 15:47:38 +09:00
Move scroll direction to scrollinginfo
This commit is contained in:
parent
48486895ba
commit
ad45bc7666
@ -22,11 +22,8 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
|
|
||||||
protected override bool UserScrollSpeedAdjustment => false;
|
protected override bool UserScrollSpeedAdjustment => false;
|
||||||
|
|
||||||
|
|
||||||
public CatchPlayfield(BeatmapDifficulty difficulty, Func<CatchHitObject, DrawableHitObject<CatchHitObject>> getVisualRepresentation)
|
public CatchPlayfield(BeatmapDifficulty difficulty, Func<CatchHitObject, DrawableHitObject<CatchHitObject>> getVisualRepresentation)
|
||||||
{
|
{
|
||||||
Direction.Value = ScrollingDirection.Down;
|
|
||||||
|
|
||||||
Container explodingFruitContainer;
|
Container explodingFruitContainer;
|
||||||
|
|
||||||
Anchor = Anchor.TopCentre;
|
Anchor = Anchor.TopCentre;
|
||||||
|
@ -24,6 +24,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
public CatchRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap)
|
public CatchRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap)
|
||||||
: base(ruleset, beatmap)
|
: base(ruleset, beatmap)
|
||||||
{
|
{
|
||||||
|
Direction.Value = ScrollingDirection.Down;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override ScoreProcessor CreateScoreProcessor() => new CatchScoreProcessor(this);
|
public override ScoreProcessor CreateScoreProcessor() => new CatchScoreProcessor(this);
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
// 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.Configuration;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Game.Rulesets.UI.Scrolling;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Tests
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// A container which provides a <see cref="IScrollingInfo"/> to children.
|
|
||||||
/// </summary>
|
|
||||||
public class ScrollingTestContainer : Container
|
|
||||||
{
|
|
||||||
[Cached(Type = typeof(IScrollingInfo))]
|
|
||||||
private readonly TestScrollingInfo scrollingInfo = new TestScrollingInfo();
|
|
||||||
|
|
||||||
public ScrollingTestContainer(ScrollingDirection direction)
|
|
||||||
{
|
|
||||||
scrollingInfo.Direction.Value = direction;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Flip() => scrollingInfo.Direction.Value = scrollingInfo.Direction.Value == ScrollingDirection.Up ? ScrollingDirection.Down : ScrollingDirection.Up;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class TestScrollingInfo : IScrollingInfo
|
|
||||||
{
|
|
||||||
public readonly Bindable<ScrollingDirection> Direction = new Bindable<ScrollingDirection>();
|
|
||||||
IBindable<ScrollingDirection> IScrollingInfo.Direction => Direction;
|
|
||||||
}
|
|
||||||
}
|
|
@ -14,6 +14,7 @@ using osu.Game.Rulesets.Mania.Objects.Drawables;
|
|||||||
using osu.Game.Rulesets.Mania.UI;
|
using osu.Game.Rulesets.Mania.UI;
|
||||||
using osu.Game.Rulesets.Mania.UI.Components;
|
using osu.Game.Rulesets.Mania.UI.Components;
|
||||||
using osu.Game.Rulesets.UI.Scrolling;
|
using osu.Game.Rulesets.UI.Scrolling;
|
||||||
|
using osu.Game.Tests.Visual;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ using osu.Game.Rulesets.Mania.Objects;
|
|||||||
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Mania.UI;
|
using osu.Game.Rulesets.Mania.UI;
|
||||||
using osu.Game.Rulesets.UI.Scrolling;
|
using osu.Game.Rulesets.UI.Scrolling;
|
||||||
|
using osu.Game.Tests.Visual;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.Tests
|
namespace osu.Game.Rulesets.Mania.Tests
|
||||||
|
@ -10,9 +10,8 @@ using osu.Game.Rulesets.Mania.Objects.Drawables;
|
|||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Game.Rulesets.Mania.Configuration;
|
using osu.Framework.Configuration;
|
||||||
using osu.Game.Rulesets.Mania.Edit.Blueprints;
|
using osu.Game.Rulesets.Mania.Edit.Blueprints;
|
||||||
using osu.Game.Rulesets.Mania.UI;
|
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
using osu.Game.Rulesets.UI.Scrolling;
|
using osu.Game.Rulesets.UI.Scrolling;
|
||||||
|
|
||||||
@ -20,8 +19,6 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
{
|
{
|
||||||
public class ManiaHitObjectComposer : HitObjectComposer<ManiaHitObject>
|
public class ManiaHitObjectComposer : HitObjectComposer<ManiaHitObject>
|
||||||
{
|
{
|
||||||
protected new ManiaConfigManager Config => (ManiaConfigManager)base.Config;
|
|
||||||
|
|
||||||
public ManiaHitObjectComposer(Ruleset ruleset)
|
public ManiaHitObjectComposer(Ruleset ruleset)
|
||||||
: base(ruleset)
|
: base(ruleset)
|
||||||
{
|
{
|
||||||
@ -30,7 +27,7 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
{
|
{
|
||||||
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||||
dependencies.CacheAs<IScrollingInfo>(new ManiaScrollingInfo(Config));
|
dependencies.CacheAs<IScrollingInfo>(new ScrollingInfo());
|
||||||
return dependencies;
|
return dependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,5 +48,10 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
|
|
||||||
return base.CreateBlueprintFor(hitObject);
|
return base.CreateBlueprintFor(hitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class ScrollingInfo : IScrollingInfo
|
||||||
|
{
|
||||||
|
public IBindable<ScrollingDirection> Direction { get; } = new Bindable<ScrollingDirection>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ using osu.Game.Rulesets.UI.Scrolling;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.UI
|
namespace osu.Game.Rulesets.Mania.UI
|
||||||
{
|
{
|
||||||
public class Column : ManiaScrollingPlayfield, IKeyBindingHandler<ManiaAction>, IHasAccentColour
|
public class Column : ScrollingPlayfield, IKeyBindingHandler<ManiaAction>, IHasAccentColour
|
||||||
{
|
{
|
||||||
private const float column_width = 45;
|
private const float column_width = 45;
|
||||||
private const float special_column_width = 70;
|
private const float special_column_width = 70;
|
||||||
@ -144,7 +144,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
|
|
||||||
explosionContainer.Add(new HitExplosion(judgedObject)
|
explosionContainer.Add(new HitExplosion(judgedObject)
|
||||||
{
|
{
|
||||||
Anchor = Direction == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre
|
Anchor = Direction.Value == ScrollingDirection.Up ? Anchor.TopCentre : Anchor.BottomCentre
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,11 +10,12 @@ using osu.Game.Rulesets.Mania.Beatmaps;
|
|||||||
using osu.Game.Rulesets.Mania.Configuration;
|
using osu.Game.Rulesets.Mania.Configuration;
|
||||||
using osu.Game.Rulesets.Mania.Objects;
|
using osu.Game.Rulesets.Mania.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.UI.Scrolling;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.UI
|
namespace osu.Game.Rulesets.Mania.UI
|
||||||
{
|
{
|
||||||
public class ManiaPlayfield : ManiaScrollingPlayfield
|
public class ManiaPlayfield : ScrollingPlayfield
|
||||||
{
|
{
|
||||||
private readonly List<ManiaStage> stages = new List<ManiaStage>();
|
private readonly List<ManiaStage> stages = new List<ManiaStage>();
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
@ -35,6 +36,8 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
|
|
||||||
protected new ManiaConfigManager Config => (ManiaConfigManager)base.Config;
|
protected new ManiaConfigManager Config => (ManiaConfigManager)base.Config;
|
||||||
|
|
||||||
|
private readonly Bindable<ManiaScrollingDirection> configDirection = new Bindable<ManiaScrollingDirection>();
|
||||||
|
|
||||||
public ManiaRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap)
|
public ManiaRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap)
|
||||||
: base(ruleset, beatmap)
|
: base(ruleset, beatmap)
|
||||||
{
|
{
|
||||||
@ -70,18 +73,9 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
BarLines.ForEach(Playfield.Add);
|
BarLines.ForEach(Playfield.Add);
|
||||||
}
|
|
||||||
|
|
||||||
private DependencyContainer dependencies;
|
Config.BindWith(ManiaSetting.ScrollDirection, configDirection);
|
||||||
|
configDirection.BindValueChanged(v => Direction.Value = (ScrollingDirection)v, true);
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
|
||||||
{
|
|
||||||
dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
|
||||||
|
|
||||||
if (dependencies.Get<ManiaScrollingInfo>() == null)
|
|
||||||
dependencies.CacheAs<IScrollingInfo>(new ManiaScrollingInfo(Config));
|
|
||||||
|
|
||||||
return dependencies;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Playfield CreatePlayfield() => new ManiaPlayfield(Beatmap.Stages)
|
protected override Playfield CreatePlayfield() => new ManiaPlayfield(Beatmap.Stages)
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
// 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.Configuration;
|
|
||||||
using osu.Game.Rulesets.Mania.Configuration;
|
|
||||||
using osu.Game.Rulesets.UI.Scrolling;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.UI
|
|
||||||
{
|
|
||||||
public class ManiaScrollingInfo : IScrollingInfo
|
|
||||||
{
|
|
||||||
private readonly Bindable<ManiaScrollingDirection> configDirection = new Bindable<ManiaScrollingDirection>();
|
|
||||||
|
|
||||||
public readonly Bindable<ScrollingDirection> Direction = new Bindable<ScrollingDirection>();
|
|
||||||
IBindable<ScrollingDirection> IScrollingInfo.Direction => Direction;
|
|
||||||
|
|
||||||
public ManiaScrollingInfo(ManiaConfigManager config)
|
|
||||||
{
|
|
||||||
config.BindWith(ManiaSetting.ScrollDirection, configDirection);
|
|
||||||
configDirection.BindValueChanged(v => Direction.Value = (ScrollingDirection)v, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
// 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.Configuration;
|
|
||||||
using osu.Game.Rulesets.UI.Scrolling;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Mania.UI
|
|
||||||
{
|
|
||||||
public abstract class ManiaScrollingPlayfield : ScrollingPlayfield
|
|
||||||
{
|
|
||||||
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(IScrollingInfo scrollingInfo)
|
|
||||||
{
|
|
||||||
direction.BindTo(scrollingInfo.Direction);
|
|
||||||
direction.BindValueChanged(direction => Direction.Value = direction, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A collection of <see cref="Column"/>s.
|
/// A collection of <see cref="Column"/>s.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ManiaStage : ManiaScrollingPlayfield
|
public class ManiaStage : ScrollingPlayfield
|
||||||
{
|
{
|
||||||
public const float HIT_TARGET_POSITION = 50;
|
public const float HIT_TARGET_POSITION = 50;
|
||||||
|
|
||||||
|
@ -56,8 +56,6 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
|
|
||||||
public TaikoPlayfield(ControlPointInfo controlPoints)
|
public TaikoPlayfield(ControlPointInfo controlPoints)
|
||||||
{
|
{
|
||||||
Direction.Value = ScrollingDirection.Left;
|
|
||||||
|
|
||||||
InternalChild = new PlayfieldAdjustmentContainer
|
InternalChild = new PlayfieldAdjustmentContainer
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
|
@ -27,6 +27,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
|||||||
public TaikoRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap)
|
public TaikoRulesetContainer(Ruleset ruleset, WorkingBeatmap beatmap)
|
||||||
: base(ruleset, beatmap)
|
: base(ruleset, beatmap)
|
||||||
{
|
{
|
||||||
|
Direction.Value = ScrollingDirection.Left;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
|
@ -4,20 +4,17 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Lists;
|
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Timing;
|
using osu.Game.Rulesets.Timing;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
using osu.Game.Rulesets.UI.Scrolling;
|
using osu.Game.Rulesets.UI.Scrolling;
|
||||||
using osu.Game.Rulesets.UI.Scrolling.Algorithms;
|
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual
|
namespace osu.Game.Tests.Visual
|
||||||
{
|
{
|
||||||
@ -26,6 +23,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(Playfield) };
|
public override IReadOnlyList<Type> RequiredTypes => new[] { typeof(Playfield) };
|
||||||
|
|
||||||
|
private readonly ScrollingTestContainer[] scrollContainers = new ScrollingTestContainer[4];
|
||||||
private readonly TestPlayfield[] playfields = new TestPlayfield[4];
|
private readonly TestPlayfield[] playfields = new TestPlayfield[4];
|
||||||
|
|
||||||
public TestCaseScrollingHitObjects()
|
public TestCaseScrollingHitObjects()
|
||||||
@ -37,13 +35,29 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
new Drawable[]
|
new Drawable[]
|
||||||
{
|
{
|
||||||
playfields[0] = new TestPlayfield(ScrollingDirection.Up),
|
scrollContainers[0] = new ScrollingTestContainer(ScrollingDirection.Up)
|
||||||
playfields[1] = new TestPlayfield(ScrollingDirection.Down)
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Child = playfields[0] = new TestPlayfield()
|
||||||
|
},
|
||||||
|
scrollContainers[1] = new ScrollingTestContainer(ScrollingDirection.Up)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Child = playfields[1] = new TestPlayfield()
|
||||||
|
},
|
||||||
},
|
},
|
||||||
new Drawable[]
|
new Drawable[]
|
||||||
{
|
{
|
||||||
playfields[2] = new TestPlayfield(ScrollingDirection.Left),
|
scrollContainers[2] = new ScrollingTestContainer(ScrollingDirection.Up)
|
||||||
playfields[3] = new TestPlayfield(ScrollingDirection.Right)
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Child = playfields[2] = new TestPlayfield()
|
||||||
|
},
|
||||||
|
scrollContainers[3] = new ScrollingTestContainer(ScrollingDirection.Up)
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Child = playfields[3] = new TestPlayfield()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -60,7 +74,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
playfields.ForEach(p => p.ControlPoints.Add(new MultiplierControlPoint(0)));
|
scrollContainers.ForEach(c => c.ControlPoints.Add(new MultiplierControlPoint(0)));
|
||||||
|
|
||||||
for (int i = 0; i <= 5000; i += 1000)
|
for (int i = 0; i <= 5000; i += 1000)
|
||||||
addHitObject(Time.Current + i);
|
addHitObject(Time.Current + i);
|
||||||
@ -81,12 +95,15 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
private void addControlPoint(double time)
|
private void addControlPoint(double time)
|
||||||
{
|
{
|
||||||
|
scrollContainers.ForEach(c =>
|
||||||
|
{
|
||||||
|
c.ControlPoints.Add(new MultiplierControlPoint(time) { DifficultyPoint = { SpeedMultiplier = 3 } });
|
||||||
|
c.ControlPoints.Add(new MultiplierControlPoint(time + 2000) { DifficultyPoint = { SpeedMultiplier = 2 } });
|
||||||
|
c.ControlPoints.Add(new MultiplierControlPoint(time + 3000) { DifficultyPoint = { SpeedMultiplier = 1 } });
|
||||||
|
});
|
||||||
|
|
||||||
playfields.ForEach(p =>
|
playfields.ForEach(p =>
|
||||||
{
|
{
|
||||||
p.ControlPoints.Add(new MultiplierControlPoint(time) { DifficultyPoint = { SpeedMultiplier = 3 } });
|
|
||||||
p.ControlPoints.Add(new MultiplierControlPoint(time + 2000) { DifficultyPoint = { SpeedMultiplier = 2 } });
|
|
||||||
p.ControlPoints.Add(new MultiplierControlPoint(time + 3000) { DifficultyPoint = { SpeedMultiplier = 1 } });
|
|
||||||
|
|
||||||
TestDrawableControlPoint createDrawablePoint(double t)
|
TestDrawableControlPoint createDrawablePoint(double t)
|
||||||
{
|
{
|
||||||
var obj = new TestDrawableControlPoint(p.Direction, t);
|
var obj = new TestDrawableControlPoint(p.Direction, t);
|
||||||
@ -119,23 +136,14 @@ namespace osu.Game.Tests.Visual
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setScrollAlgorithm(ScrollAlgorithm algorithm) => playfields.ForEach(p => p.ScrollAlgorithm = algorithm);
|
private void setScrollAlgorithm(ScrollAlgorithm algorithm) => scrollContainers.ForEach(c => c.ScrollAlgorithm = algorithm);
|
||||||
|
|
||||||
private class TestPlayfield : ScrollingPlayfield
|
private class TestPlayfield : ScrollingPlayfield
|
||||||
{
|
{
|
||||||
public new ScrollingDirection Direction => base.Direction;
|
public new ScrollingDirection Direction => base.Direction.Value;
|
||||||
|
|
||||||
public SortedList<MultiplierControlPoint> ControlPoints => algorithm.ControlPoints;
|
public TestPlayfield()
|
||||||
|
|
||||||
public ScrollAlgorithm ScrollAlgorithm { set => algorithm.Algorithm = value; }
|
|
||||||
|
|
||||||
[Cached(Type = typeof(IScrollAlgorithm))]
|
|
||||||
private readonly TestScrollAlgorithm algorithm = new TestScrollAlgorithm();
|
|
||||||
|
|
||||||
public TestPlayfield(ScrollingDirection direction)
|
|
||||||
{
|
{
|
||||||
base.Direction.Value = direction;
|
|
||||||
|
|
||||||
Padding = new MarginPadding(2);
|
Padding = new MarginPadding(2);
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
InternalChildren = new Drawable[]
|
||||||
@ -155,49 +163,6 @@ namespace osu.Game.Tests.Visual
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestScrollAlgorithm : IScrollAlgorithm
|
|
||||||
{
|
|
||||||
public readonly SortedList<MultiplierControlPoint> ControlPoints = new SortedList<MultiplierControlPoint>();
|
|
||||||
|
|
||||||
private IScrollAlgorithm implementation;
|
|
||||||
|
|
||||||
public TestScrollAlgorithm()
|
|
||||||
{
|
|
||||||
Algorithm = ScrollAlgorithm.Constant;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ScrollAlgorithm Algorithm
|
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
switch (value)
|
|
||||||
{
|
|
||||||
case ScrollAlgorithm.Constant:
|
|
||||||
implementation = new ConstantScrollAlgorithm();
|
|
||||||
break;
|
|
||||||
case ScrollAlgorithm.Overlapping:
|
|
||||||
implementation = new OverlappingScrollAlgorithm(ControlPoints);
|
|
||||||
break;
|
|
||||||
case ScrollAlgorithm.Sequential:
|
|
||||||
implementation = new SequentialScrollAlgorithm(ControlPoints);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public double GetDisplayStartTime(double time, double timeRange)
|
|
||||||
=> implementation.GetDisplayStartTime(time, timeRange);
|
|
||||||
|
|
||||||
public float GetLength(double startTime, double endTime, double timeRange, float scrollLength)
|
|
||||||
=> implementation.GetLength(startTime, endTime, timeRange, scrollLength);
|
|
||||||
|
|
||||||
public float PositionAt(double time, double currentTime, double timeRange, float scrollLength)
|
|
||||||
=> implementation.PositionAt(time, currentTime, timeRange, scrollLength);
|
|
||||||
|
|
||||||
public void Reset()
|
|
||||||
=> implementation.Reset();
|
|
||||||
}
|
|
||||||
|
|
||||||
private class TestDrawableControlPoint : DrawableHitObject<HitObject>
|
private class TestDrawableControlPoint : DrawableHitObject<HitObject>
|
||||||
{
|
{
|
||||||
public TestDrawableControlPoint(ScrollingDirection direction, double time)
|
public TestDrawableControlPoint(ScrollingDirection direction, double time)
|
||||||
|
@ -22,11 +22,14 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
|||||||
MaxValue = double.MaxValue
|
MaxValue = double.MaxValue
|
||||||
};
|
};
|
||||||
|
|
||||||
public readonly Bindable<ScrollingDirection> Direction = new Bindable<ScrollingDirection>();
|
private readonly IBindable<ScrollingDirection> direction = new Bindable<ScrollingDirection>();
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private IScrollAlgorithm algorithm { get; set; }
|
private IScrollAlgorithm algorithm { get; set; }
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private IScrollingInfo scrollingInfo { get; set; }
|
||||||
|
|
||||||
private Cached initialStateCache = new Cached();
|
private Cached initialStateCache = new Cached();
|
||||||
|
|
||||||
public ScrollingHitObjectContainer()
|
public ScrollingHitObjectContainer()
|
||||||
@ -34,7 +37,13 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
|||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
TimeRange.ValueChanged += _ => initialStateCache.Invalidate();
|
TimeRange.ValueChanged += _ => initialStateCache.Invalidate();
|
||||||
Direction.ValueChanged += _ => initialStateCache.Invalidate();
|
direction.ValueChanged += _ => initialStateCache.Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
direction.BindTo(scrollingInfo.Direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Add(DrawableHitObject hitObject)
|
public override void Add(DrawableHitObject hitObject)
|
||||||
@ -67,7 +76,7 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
|||||||
|
|
||||||
if (!initialStateCache.IsValid)
|
if (!initialStateCache.IsValid)
|
||||||
{
|
{
|
||||||
switch (Direction.Value)
|
switch (direction.Value)
|
||||||
{
|
{
|
||||||
case ScrollingDirection.Up:
|
case ScrollingDirection.Up:
|
||||||
case ScrollingDirection.Down:
|
case ScrollingDirection.Down:
|
||||||
@ -92,7 +101,7 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
|||||||
|
|
||||||
if (hitObject.HitObject is IHasEndTime endTime)
|
if (hitObject.HitObject is IHasEndTime endTime)
|
||||||
{
|
{
|
||||||
switch (Direction.Value)
|
switch (direction.Value)
|
||||||
{
|
{
|
||||||
case ScrollingDirection.Up:
|
case ScrollingDirection.Up:
|
||||||
case ScrollingDirection.Down:
|
case ScrollingDirection.Down:
|
||||||
@ -125,7 +134,7 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
|||||||
|
|
||||||
private void updatePosition(DrawableHitObject hitObject, double currentTime)
|
private void updatePosition(DrawableHitObject hitObject, double currentTime)
|
||||||
{
|
{
|
||||||
switch (Direction.Value)
|
switch (direction.Value)
|
||||||
{
|
{
|
||||||
case ScrollingDirection.Up:
|
case ScrollingDirection.Up:
|
||||||
hitObject.Y = algorithm.PositionAt(hitObject.HitObject.StartTime, currentTime, TimeRange, scrollLength);
|
hitObject.Y = algorithm.PositionAt(hitObject.HitObject.StartTime, currentTime, TimeRange, scrollLength);
|
||||||
|
@ -52,19 +52,20 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual bool UserScrollSpeedAdjustment => true;
|
protected virtual bool UserScrollSpeedAdjustment => true;
|
||||||
|
|
||||||
|
protected readonly IBindable<ScrollingDirection> Direction = new Bindable<ScrollingDirection>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The container that contains the <see cref="DrawableHitObject"/>s.
|
/// The container that contains the <see cref="DrawableHitObject"/>s.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public new ScrollingHitObjectContainer HitObjects => (ScrollingHitObjectContainer)HitObjectContainer;
|
public new ScrollingHitObjectContainer HitObjects => (ScrollingHitObjectContainer)HitObjectContainer;
|
||||||
|
|
||||||
/// <summary>
|
[Resolved]
|
||||||
/// The direction in which <see cref="DrawableHitObject"/>s in this <see cref="ScrollingPlayfield"/> should scroll.
|
private IScrollingInfo scrollingInfo { get; set; }
|
||||||
/// </summary>
|
|
||||||
protected readonly Bindable<ScrollingDirection> Direction = new Bindable<ScrollingDirection>();
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
|
Direction.BindTo(scrollingInfo.Direction);
|
||||||
HitObjects.TimeRange.BindTo(VisibleTimeRange);
|
HitObjects.TimeRange.BindTo(VisibleTimeRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,11 +89,6 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
|||||||
|
|
||||||
public bool OnReleased(GlobalAction action) => false;
|
public bool OnReleased(GlobalAction action) => false;
|
||||||
|
|
||||||
protected sealed override HitObjectContainer CreateHitObjectContainer()
|
protected sealed override HitObjectContainer CreateHitObjectContainer() => new ScrollingHitObjectContainer();
|
||||||
{
|
|
||||||
var container = new ScrollingHitObjectContainer();
|
|
||||||
container.Direction.BindTo(Direction);
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Lists;
|
using osu.Framework.Lists;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.ControlPoints;
|
using osu.Game.Beatmaps.ControlPoints;
|
||||||
@ -23,6 +24,10 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
|||||||
where TObject : HitObject
|
where TObject : HitObject
|
||||||
where TPlayfield : ScrollingPlayfield
|
where TPlayfield : ScrollingPlayfield
|
||||||
{
|
{
|
||||||
|
protected readonly Bindable<ScrollingDirection> Direction = new Bindable<ScrollingDirection>();
|
||||||
|
|
||||||
|
protected virtual ScrollAlgorithm ScrollAlgorithm => ScrollAlgorithm.Sequential;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Provides the default <see cref="MultiplierControlPoint"/>s that adjust the scrolling rate of <see cref="HitObject"/>s
|
/// Provides the default <see cref="MultiplierControlPoint"/>s that adjust the scrolling rate of <see cref="HitObject"/>s
|
||||||
/// inside this <see cref="RulesetContainer{TPlayfield,TObject}"/>.
|
/// inside this <see cref="RulesetContainer{TPlayfield,TObject}"/>.
|
||||||
@ -30,7 +35,7 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private readonly SortedList<MultiplierControlPoint> controlPoints = new SortedList<MultiplierControlPoint>(Comparer<MultiplierControlPoint>.Default);
|
private readonly SortedList<MultiplierControlPoint> controlPoints = new SortedList<MultiplierControlPoint>(Comparer<MultiplierControlPoint>.Default);
|
||||||
|
|
||||||
protected virtual ScrollAlgorithm ScrollAlgorithm => ScrollAlgorithm.Sequential;
|
private IScrollingInfo scrollingInfo;
|
||||||
|
|
||||||
[Cached(Type = typeof(IScrollAlgorithm))]
|
[Cached(Type = typeof(IScrollAlgorithm))]
|
||||||
private readonly IScrollAlgorithm algorithm;
|
private readonly IScrollAlgorithm algorithm;
|
||||||
@ -55,6 +60,8 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
|
scrollingInfo.Direction.BindTo(Direction);
|
||||||
|
|
||||||
// Calculate default multiplier control points
|
// Calculate default multiplier control points
|
||||||
var lastTimingPoint = new TimingControlPoint();
|
var lastTimingPoint = new TimingControlPoint();
|
||||||
var lastDifficultyPoint = new DifficultyControlPoint();
|
var lastDifficultyPoint = new DifficultyControlPoint();
|
||||||
@ -99,5 +106,22 @@ namespace osu.Game.Rulesets.UI.Scrolling
|
|||||||
if (controlPoints.Count == 0)
|
if (controlPoints.Count == 0)
|
||||||
controlPoints.Add(new MultiplierControlPoint { Velocity = Beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier });
|
controlPoints.Add(new MultiplierControlPoint { Velocity = Beatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
|
{
|
||||||
|
var dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
|
||||||
|
|
||||||
|
if ((scrollingInfo = dependencies.Get<IScrollingInfo>()) == null)
|
||||||
|
dependencies.CacheAs(scrollingInfo = CreateScrollingInfo());
|
||||||
|
|
||||||
|
return dependencies;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual IScrollingInfo CreateScrollingInfo() => new ScrollingInfo();
|
||||||
|
|
||||||
|
private class ScrollingInfo : IScrollingInfo
|
||||||
|
{
|
||||||
|
public IBindable<ScrollingDirection> Direction { get; } = new Bindable<ScrollingDirection>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
87
osu.Game/Tests/Visual/ScrollingTestContainer.cs
Normal file
87
osu.Game/Tests/Visual/ScrollingTestContainer.cs
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
// 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.Configuration;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Lists;
|
||||||
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Rulesets.Timing;
|
||||||
|
using osu.Game.Rulesets.UI.Scrolling;
|
||||||
|
using osu.Game.Rulesets.UI.Scrolling.Algorithms;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A container which provides a <see cref="IScrollingInfo"/> to children.
|
||||||
|
/// This should only be used when testing
|
||||||
|
/// </summary>
|
||||||
|
public class ScrollingTestContainer : Container
|
||||||
|
{
|
||||||
|
public SortedList<MultiplierControlPoint> ControlPoints => scrollAlgorithm.ControlPoints;
|
||||||
|
|
||||||
|
public ScrollAlgorithm ScrollAlgorithm { set => scrollAlgorithm.Algorithm = value; }
|
||||||
|
|
||||||
|
[Cached(Type = typeof(IScrollingInfo))]
|
||||||
|
private readonly TestScrollingInfo scrollingInfo = new TestScrollingInfo();
|
||||||
|
|
||||||
|
[Cached(Type = typeof(IScrollAlgorithm))]
|
||||||
|
private readonly TestScrollAlgorithm scrollAlgorithm = new TestScrollAlgorithm();
|
||||||
|
|
||||||
|
public ScrollingTestContainer(ScrollingDirection direction)
|
||||||
|
{
|
||||||
|
scrollingInfo.Direction.Value = direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Flip() => scrollingInfo.Direction.Value = scrollingInfo.Direction.Value == ScrollingDirection.Up ? ScrollingDirection.Down : ScrollingDirection.Up;
|
||||||
|
|
||||||
|
private class TestScrollingInfo : IScrollingInfo
|
||||||
|
{
|
||||||
|
public readonly Bindable<ScrollingDirection> Direction = new Bindable<ScrollingDirection>();
|
||||||
|
IBindable<ScrollingDirection> IScrollingInfo.Direction => Direction;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class TestScrollAlgorithm : IScrollAlgorithm
|
||||||
|
{
|
||||||
|
public readonly SortedList<MultiplierControlPoint> ControlPoints = new SortedList<MultiplierControlPoint>();
|
||||||
|
|
||||||
|
private IScrollAlgorithm implementation;
|
||||||
|
|
||||||
|
public TestScrollAlgorithm()
|
||||||
|
{
|
||||||
|
Algorithm = ScrollAlgorithm.Constant;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ScrollAlgorithm Algorithm
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
switch (value)
|
||||||
|
{
|
||||||
|
case ScrollAlgorithm.Constant:
|
||||||
|
implementation = new ConstantScrollAlgorithm();
|
||||||
|
break;
|
||||||
|
case ScrollAlgorithm.Overlapping:
|
||||||
|
implementation = new OverlappingScrollAlgorithm(ControlPoints);
|
||||||
|
break;
|
||||||
|
case ScrollAlgorithm.Sequential:
|
||||||
|
implementation = new SequentialScrollAlgorithm(ControlPoints);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public double GetDisplayStartTime(double time, double timeRange)
|
||||||
|
=> implementation.GetDisplayStartTime(time, timeRange);
|
||||||
|
|
||||||
|
public float GetLength(double startTime, double endTime, double timeRange, float scrollLength)
|
||||||
|
=> implementation.GetLength(startTime, endTime, timeRange, scrollLength);
|
||||||
|
|
||||||
|
public float PositionAt(double time, double currentTime, double timeRange, float scrollLength)
|
||||||
|
=> implementation.PositionAt(time, currentTime, timeRange, scrollLength);
|
||||||
|
|
||||||
|
public void Reset()
|
||||||
|
=> implementation.Reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user