mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 19:27:26 +08:00
parent
7a24e5f509
commit
32c3e34eb7
@ -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 @@ namespace osu.Desktop.VisualTests.Tests
|
||||
Clock = new FramedClock(rateAdjustClock),
|
||||
Children = new[]
|
||||
{
|
||||
playfield = new TaikoPlayfield
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Height = 0.75f
|
||||
}
|
||||
playfield = new TaikoPlayfield()
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -52,8 +52,6 @@ namespace osu.Game.Modes.Taiko.UI
|
||||
|
||||
public TaikoPlayfield()
|
||||
{
|
||||
Masking = true;
|
||||
|
||||
AddInternal(new Drawable[]
|
||||
{
|
||||
rightBackgroundContainer = new Container
|
||||
@ -113,9 +111,11 @@ namespace osu.Game.Modes.Taiko.UI
|
||||
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 @@ namespace osu.Game.Modes.Taiko.UI
|
||||
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 @@ 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
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user