mirror of
https://github.com/ppy/osu
synced 2025-02-22 13:37:08 +00:00
Use enum values instead of class override
This commit is contained in:
parent
03a7b8a6ef
commit
8d9e5db641
@ -1,7 +1,6 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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;
|
||||
}
|
||||
}
|
||||
|
@ -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<ManiaHitObject>) };
|
||||
|
||||
/// <summary>
|
||||
/// The direction in which the cover should expand.
|
||||
/// </summary>
|
||||
protected virtual CoverExpandDirection ExpandDirection => CoverExpandDirection.AgainstScroll;
|
||||
|
||||
public virtual void ApplyToDrawableRuleset(DrawableRuleset<ManiaHitObject> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
/// <summary>
|
||||
/// A <see cref="Container"/> that has its contents partially hidden by an adjustable "cover". This is intended to be used in a playfield.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The covered area extends in the scrolling direction, with its size depending on <see cref="Coverage"/>.
|
||||
/// </remarks>
|
||||
public class PlayfieldCoveringWrapper : CompositeDrawable
|
||||
{
|
||||
/// <summary>
|
||||
/// The complete cover, including gradient and fill.
|
||||
/// </summary>
|
||||
protected readonly Drawable Cover;
|
||||
private readonly Drawable cover;
|
||||
|
||||
/// <summary>
|
||||
/// 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<ScrollingDirection> direction)
|
||||
=> Cover.Rotation = direction.NewValue == ScrollingDirection.Up ? 0 : 180f;
|
||||
=> cover.Rotation = direction.NewValue == ScrollingDirection.Up ? 0 : 180f;
|
||||
|
||||
/// <summary>
|
||||
/// 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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The direction in which the cover expands.
|
||||
/// </summary>
|
||||
public CoverExpandDirection Direction
|
||||
{
|
||||
set => cover.Scale = value == CoverExpandDirection.AlongScroll ? Vector2.One : new Vector2(1, -1);
|
||||
}
|
||||
}
|
||||
|
||||
public enum CoverExpandDirection
|
||||
{
|
||||
/// <summary>
|
||||
/// The cover expands along the scrolling direction.
|
||||
/// </summary>
|
||||
AlongScroll,
|
||||
|
||||
/// <summary>
|
||||
/// The cover expands against the scrolling direction.
|
||||
/// </summary>
|
||||
AgainstScroll
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user