1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-15 23:42:55 +08:00

Revert "Better masking."

This reverts commit 5d5040ee73.
This commit is contained in:
smoogipooo 2017-04-12 15:00:26 +09:00
parent 7a24e5f509
commit 32c3e34eb7
2 changed files with 35 additions and 26 deletions

View File

@ -4,7 +4,6 @@
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.Primitives;
using osu.Framework.MathUtils; using osu.Framework.MathUtils;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Framework.Timing; using osu.Framework.Timing;
@ -64,12 +63,7 @@ namespace osu.Desktop.VisualTests.Tests
Clock = new FramedClock(rateAdjustClock), Clock = new FramedClock(rateAdjustClock),
Children = new[] Children = new[]
{ {
playfield = new TaikoPlayfield playfield = new TaikoPlayfield()
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Height = 0.75f
}
} }
}); });
} }

View File

@ -52,8 +52,6 @@ namespace osu.Game.Modes.Taiko.UI
public TaikoPlayfield() public TaikoPlayfield()
{ {
Masking = true;
AddInternal(new Drawable[] AddInternal(new Drawable[]
{ {
rightBackgroundContainer = new Container rightBackgroundContainer = new Container
@ -113,9 +111,11 @@ namespace osu.Game.Modes.Taiko.UI
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.Centre, Origin = Anchor.Centre,
}, },
hitObjectContainer = new Container hitObjectContainer = new ExternalMaskingRectangleContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Masking = true,
MaskingReference = () => this
}, },
judgementContainer = new Container<DrawableTaikoJudgement> judgementContainer = new Container<DrawableTaikoJudgement>
{ {
@ -221,22 +221,6 @@ namespace osu.Game.Modes.Taiko.UI
hitExplosionContainer.Children.FirstOrDefault(e => e.Judgement == judgedObject.Judgement)?.VisualiseSecondHit(); hitExplosionContainer.Children.FirstOrDefault(e => e.Judgement == judgedObject.Judgement)?.VisualiseSecondHit();
} }
protected override void ApplyDrawNode(DrawNode node)
{
base.ApplyDrawNode(node);
var cn = node as ContainerDrawNode;
if (!Masking)
return;
MaskingInfo old = cn.MaskingInfo.Value;
old.MaskingRect = new RectangleF(old.MaskingRect.X, old.MaskingRect.Y - 2000, old.MaskingRect.Width, old.MaskingRect.Height + 4000);
old.ScreenSpaceAABB = new System.Drawing.Rectangle(old.ScreenSpaceAABB.X, old.ScreenSpaceAABB.Y - 2000, old.ScreenSpaceAABB.Width, old.ScreenSpaceAABB.Height + 4000);
cn.MaskingInfo = old;
}
/// <summary> /// <summary>
/// This is a very special type of container. It serves a similar purpose to <see cref="FillMode.Fit"/>, however unlike <see cref="FillMode.Fit"/>, /// This is a very special type of container. It serves a similar purpose to <see cref="FillMode.Fit"/>, however unlike <see cref="FillMode.Fit"/>,
/// this will only adjust the scale relative to the height of its parent and will maintain the original width relative to its parent. /// this will only adjust the scale relative to the height of its parent and will maintain the original width relative to its parent.
@ -287,5 +271,36 @@ namespace osu.Game.Modes.Taiko.UI
} }
} }
} }
private class ExternalMaskingRectangleContainer : Container
{
public Func<Drawable> MaskingReference;
protected override void ApplyDrawNode(DrawNode node)
{
base.ApplyDrawNode(node);
Drawable maskingReference = MaskingReference?.Invoke();
if (MaskingReference == null)
return;
var cn = node as ContainerDrawNode;
cn.MaskingInfo = !Masking
? (MaskingInfo?)null
: new MaskingInfo
{
ScreenSpaceAABB = maskingReference.ScreenSpaceDrawQuad.AABB,
MaskingRect = maskingReference.DrawRectangle,
ToMaskingSpace = cn.MaskingInfo.Value.ToMaskingSpace,
CornerRadius = cn.MaskingInfo.Value.CornerRadius,
BorderThickness = cn.MaskingInfo.Value.BorderThickness,
BorderColour = cn.MaskingInfo.Value.BorderColour,
BlendRange = cn.MaskingInfo.Value.BlendRange,
AlphaExponent = cn.MaskingInfo.Value.AlphaExponent
};
}
}
} }
} }