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 osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives;
using osu.Framework.MathUtils;
using osu.Framework.Testing;
using osu.Framework.Timing;
@ -64,12 +63,7 @@ public override void Reset()
Clock = new FramedClock(rateAdjustClock),
Children = new[]
{
playfield = new TaikoPlayfield
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Height = 0.75f
}
playfield = new TaikoPlayfield()
}
});
}

View File

@ -52,8 +52,6 @@ public class TaikoPlayfield : Playfield<TaikoHitObject, TaikoJudgement>
public TaikoPlayfield()
{
Masking = true;
AddInternal(new Drawable[]
{
rightBackgroundContainer = new Container
@ -113,9 +111,11 @@ public TaikoPlayfield()
Anchor = Anchor.CentreLeft,
Origin = Anchor.Centre,
},
hitObjectContainer = new Container
hitObjectContainer = new ExternalMaskingRectangleContainer
{
RelativeSizeAxes = Axes.Both,
Masking = true,
MaskingReference = () => this
},
judgementContainer = new Container<DrawableTaikoJudgement>
{
@ -221,22 +221,6 @@ public override void OnJudgement(DrawableHitObject<TaikoHitObject, TaikoJudgemen
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>
/// 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.
@ -287,5 +271,36 @@ protected override void Update()
}
}
}
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
};
}
}
}
}