Merge branch 'master' into shift-delete

This commit is contained in:
David Zhao
2019-07-23 13:25:12 +09:00
committed by GitHub
63 changed files with 635 additions and 311 deletions

View File

@ -16,7 +16,7 @@ namespace osu.Game.Graphics.Backgrounds
/// </summary>
public class Background : CompositeDrawable
{
public Sprite Sprite;
public readonly Sprite Sprite;
private readonly string textureName;
@ -51,7 +51,7 @@ namespace osu.Game.Graphics.Backgrounds
/// <returns>A <see cref="TransformSequence{T}"/> to which further transforms can be added.</returns>
public void BlurTo(Vector2 newBlurSigma, double duration = 0, Easing easing = Easing.None)
{
if (bufferedContainer == null)
if (bufferedContainer == null && newBlurSigma != Vector2.Zero)
{
RemoveInternal(Sprite);
@ -63,7 +63,7 @@ namespace osu.Game.Graphics.Backgrounds
});
}
bufferedContainer.BlurTo(newBlurSigma, duration, easing);
bufferedContainer?.BlurTo(newBlurSigma, duration, easing);
}
}
}

View File

@ -8,7 +8,6 @@ using osuTK.Graphics;
using System;
using osu.Framework.Graphics.Shaders;
using osu.Framework.Graphics.Textures;
using osuTK.Graphics.ES30;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Allocation;
@ -137,11 +136,13 @@ namespace osu.Game.Graphics.Backgrounds
}
}
protected int AimCount;
private void addTriangles(bool randomY)
{
int aimTriangleCount = (int)(DrawWidth * DrawHeight * 0.002f / (triangleScale * triangleScale) * SpawnRatio);
AimCount = (int)(DrawWidth * DrawHeight * 0.002f / (triangleScale * triangleScale) * SpawnRatio);
for (int i = 0; i < aimTriangleCount - parts.Count; i++)
for (int i = 0; i < AimCount - parts.Count; i++)
parts.Add(createTriangle(randomY));
}
@ -190,7 +191,7 @@ namespace osu.Game.Graphics.Backgrounds
private readonly List<TriangleParticle> parts = new List<TriangleParticle>();
private Vector2 size;
private readonly LinearBatch<TexturedVertex2D> vertexBatch = new LinearBatch<TexturedVertex2D>(100 * 3, 10, PrimitiveType.Triangles);
private TriangleBatch<TexturedVertex2D> vertexBatch;
public TrianglesDrawNode(Triangles source)
: base(source)
@ -213,6 +214,12 @@ namespace osu.Game.Graphics.Backgrounds
{
base.Draw(vertexAction);
if (Source.AimCount > 0 && (vertexBatch == null || vertexBatch.Size != Source.AimCount))
{
vertexBatch?.Dispose();
vertexBatch = new TriangleBatch<TexturedVertex2D>(Source.AimCount, 1);
}
shader.Bind();
Vector2 localInflationAmount = edge_smoothness * DrawInfo.MatrixInverse.ExtractScale().Xy;
@ -246,7 +253,7 @@ namespace osu.Game.Graphics.Backgrounds
{
base.Dispose(isDisposing);
vertexBatch.Dispose();
vertexBatch?.Dispose();
}
}

View File

@ -0,0 +1,80 @@
// 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.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osuTK;
namespace osu.Game.Graphics.Sprites
{
public class GlowingSpriteText : Container, IHasText
{
private readonly OsuSpriteText spriteText, blurredText;
public string Text
{
get => spriteText.Text;
set => blurredText.Text = spriteText.Text = value;
}
public FontUsage Font
{
get => spriteText.Font;
set => blurredText.Font = spriteText.Font = value.With(fixedWidth: true);
}
public Vector2 TextSize
{
get => spriteText.Size;
set => blurredText.Size = spriteText.Size = value;
}
public ColourInfo TextColour
{
get => spriteText.Colour;
set => spriteText.Colour = value;
}
public ColourInfo GlowColour
{
get => blurredText.Colour;
set => blurredText.Colour = value;
}
public GlowingSpriteText()
{
AutoSizeAxes = Axes.Both;
Children = new Drawable[]
{
new BufferedContainer
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
BlurSigma = new Vector2(4),
CacheDrawnFrameBuffer = true,
RelativeSizeAxes = Axes.Both,
Blending = BlendingMode.Additive,
Size = new Vector2(3f),
Children = new[]
{
blurredText = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Shadow = false,
},
},
},
spriteText = new OsuSpriteText
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Shadow = false,
},
};
}
}
}