Pass in content

This commit is contained in:
smoogipoo 2020-07-16 21:17:51 +09:00
parent 967238e269
commit 18d3685023
4 changed files with 14 additions and 17 deletions

View File

@ -24,14 +24,13 @@ namespace osu.Game.Rulesets.Mania.Tests
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Size = new Vector2(300, 500), Size = new Vector2(300, 500),
Child = cover = new PlayfieldCoveringContainer Child = cover = new PlayfieldCoveringContainer(new Box
{
RelativeSizeAxes = Axes.Both,
Child = new Box
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Colour = Color4.Orange Colour = Color4.Orange
} })
{
RelativeSizeAxes = Axes.Both,
} }
}; };
} }

View File

@ -1,6 +1,7 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Rulesets.Mania.UI; using osu.Game.Rulesets.Mania.UI;
@ -14,6 +15,6 @@ namespace osu.Game.Rulesets.Mania.Mods
public override IconUsage? Icon => OsuIcon.ModHidden; public override IconUsage? Icon => OsuIcon.ModHidden;
public override string Description => @"Keys appear out of nowhere!"; public override string Description => @"Keys appear out of nowhere!";
protected override PlayfieldCoveringContainer CreateCover() => new PlayfieldCoveringContainer(); protected override PlayfieldCoveringContainer CreateCover(Drawable content) => new PlayfieldCoveringContainer(content);
} }
} }

View File

@ -29,7 +29,7 @@ namespace osu.Game.Rulesets.Mania.Mods
Container hocParent = (Container)hoc.Parent; Container hocParent = (Container)hoc.Parent;
hocParent.Remove(hoc); hocParent.Remove(hoc);
hocParent.Add(CreateCover().WithChild(hoc).With(c => hocParent.Add(CreateCover(hoc).With(c =>
{ {
c.RelativeSizeAxes = Axes.Both; c.RelativeSizeAxes = Axes.Both;
c.Coverage = 0.5f; c.Coverage = 0.5f;
@ -37,11 +37,12 @@ namespace osu.Game.Rulesets.Mania.Mods
} }
} }
protected virtual PlayfieldCoveringContainer CreateCover() => new ModHiddenCoveringContainer(); protected virtual PlayfieldCoveringContainer CreateCover(Drawable content) => new ModHiddenCoveringContainer(content);
private class ModHiddenCoveringContainer : PlayfieldCoveringContainer private class ModHiddenCoveringContainer : PlayfieldCoveringContainer
{ {
public ModHiddenCoveringContainer() public ModHiddenCoveringContainer(Drawable content)
: base(content)
{ {
// This cover extends outwards from the hit position. // This cover extends outwards from the hit position.
Cover.Scale = new Vector2(1, -1); Cover.Scale = new Vector2(1, -1);

View File

@ -19,12 +19,8 @@ namespace osu.Game.Rulesets.Mania.UI
/// <remarks> /// <remarks>
/// The covered area extends in the scrolling direction, with its size depending on <see cref="Coverage"/>. /// The covered area extends in the scrolling direction, with its size depending on <see cref="Coverage"/>.
/// </remarks> /// </remarks>
public class PlayfieldCoveringContainer : Container public class PlayfieldCoveringContainer : CompositeDrawable
{ {
protected override Container<Drawable> Content => content;
private readonly Container content;
/// <summary> /// <summary>
/// The complete cover, including gradient and fill. /// The complete cover, including gradient and fill.
/// </summary> /// </summary>
@ -42,14 +38,14 @@ namespace osu.Game.Rulesets.Mania.UI
private readonly IBindable<ScrollingDirection> scrollDirection = new Bindable<ScrollingDirection>(); private readonly IBindable<ScrollingDirection> scrollDirection = new Bindable<ScrollingDirection>();
public PlayfieldCoveringContainer() public PlayfieldCoveringContainer(Drawable content)
{ {
InternalChild = new BufferedContainer InternalChild = new BufferedContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Children = new[] Children = new[]
{ {
content = new Container { RelativeSizeAxes = Axes.Both }, content,
Cover = new Container Cover = new Container
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,