diff --git a/osu.Game.Rulesets.Mania/Mods/ManiaModFadeIn.cs b/osu.Game.Rulesets.Mania/Mods/ManiaModFadeIn.cs index 3893b83db9..cbdcd49c5b 100644 --- a/osu.Game.Rulesets.Mania/Mods/ManiaModFadeIn.cs +++ b/osu.Game.Rulesets.Mania/Mods/ManiaModFadeIn.cs @@ -1,7 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -using osu.Framework.Graphics; using osu.Framework.Graphics.Sprites; using osu.Game.Graphics; using osu.Game.Rulesets.Mania.UI; @@ -15,6 +14,6 @@ namespace osu.Game.Rulesets.Mania.Mods public override IconUsage? Icon => OsuIcon.ModHidden; public override string Description => @"Keys appear out of nowhere!"; - protected override PlayfieldCoveringWrapper CreateCover(Drawable content) => new PlayfieldCoveringWrapper(content); + protected override CoverExpandDirection ExpandDirection => CoverExpandDirection.AlongScroll; } } diff --git a/osu.Game.Rulesets.Mania/Mods/ManiaModHidden.cs b/osu.Game.Rulesets.Mania/Mods/ManiaModHidden.cs index e460ccee9c..4bdb15526f 100644 --- a/osu.Game.Rulesets.Mania/Mods/ManiaModHidden.cs +++ b/osu.Game.Rulesets.Mania/Mods/ManiaModHidden.cs @@ -9,7 +9,6 @@ using osu.Game.Rulesets.Mania.Objects; using osu.Game.Rulesets.Mania.UI; using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.UI; -using osuTK; namespace osu.Game.Rulesets.Mania.Mods { @@ -19,6 +18,11 @@ namespace osu.Game.Rulesets.Mania.Mods public override double ScoreMultiplier => 1; public override Type[] IncompatibleMods => new[] { typeof(ModFlashlight) }; + /// + /// The direction in which the cover should expand. + /// + protected virtual CoverExpandDirection ExpandDirection => CoverExpandDirection.AgainstScroll; + public virtual void ApplyToDrawableRuleset(DrawableRuleset drawableRuleset) { ManiaPlayfield maniaPlayfield = (ManiaPlayfield)drawableRuleset.Playfield; @@ -29,24 +33,13 @@ namespace osu.Game.Rulesets.Mania.Mods Container hocParent = (Container)hoc.Parent; hocParent.Remove(hoc); - hocParent.Add(CreateCover(hoc).With(c => + hocParent.Add(new PlayfieldCoveringWrapper(hoc).With(c => { c.RelativeSizeAxes = Axes.Both; + c.Direction = ExpandDirection; c.Coverage = 0.5f; })); } } - - protected virtual PlayfieldCoveringWrapper CreateCover(Drawable content) => new ModHiddenCoveringWrapper(content); - - private class ModHiddenCoveringWrapper : PlayfieldCoveringWrapper - { - public ModHiddenCoveringWrapper(Drawable content) - : base(content) - { - // This cover extends outwards from the hit position. - Cover.Scale = new Vector2(1, -1); - } - } } } diff --git a/osu.Game.Rulesets.Mania/UI/PlayfieldCoveringWrapper.cs b/osu.Game.Rulesets.Mania/UI/PlayfieldCoveringWrapper.cs index 207239dd38..15d216e8c5 100644 --- a/osu.Game.Rulesets.Mania/UI/PlayfieldCoveringWrapper.cs +++ b/osu.Game.Rulesets.Mania/UI/PlayfieldCoveringWrapper.cs @@ -9,6 +9,7 @@ using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Game.Rulesets.UI.Scrolling; +using osuTK; using osuTK.Graphics; namespace osu.Game.Rulesets.Mania.UI @@ -16,15 +17,12 @@ namespace osu.Game.Rulesets.Mania.UI /// /// A that has its contents partially hidden by an adjustable "cover". This is intended to be used in a playfield. /// - /// - /// The covered area extends in the scrolling direction, with its size depending on . - /// public class PlayfieldCoveringWrapper : CompositeDrawable { /// /// The complete cover, including gradient and fill. /// - protected readonly Drawable Cover; + private readonly Drawable cover; /// /// The gradient portion of the cover. @@ -46,7 +44,7 @@ namespace osu.Game.Rulesets.Mania.UI Children = new[] { content, - Cover = new Container + cover = new Container { Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -97,7 +95,7 @@ namespace osu.Game.Rulesets.Mania.UI } private void onScrollDirectionChanged(ValueChangedEvent direction) - => Cover.Rotation = direction.NewValue == ScrollingDirection.Up ? 0 : 180f; + => cover.Rotation = direction.NewValue == ScrollingDirection.Up ? 0 : 180f; /// /// The relative area that should be completely covered. This does not include the fade. @@ -110,5 +108,26 @@ namespace osu.Game.Rulesets.Mania.UI gradient.Y = -value; } } + + /// + /// The direction in which the cover expands. + /// + public CoverExpandDirection Direction + { + set => cover.Scale = value == CoverExpandDirection.AlongScroll ? Vector2.One : new Vector2(1, -1); + } + } + + public enum CoverExpandDirection + { + /// + /// The cover expands along the scrolling direction. + /// + AlongScroll, + + /// + /// The cover expands against the scrolling direction. + /// + AgainstScroll } }