1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-27 13:53:10 +08:00
osu-lazer/osu.Game/Graphics/Sprites/LogoAnimation.cs

70 lines
2.0 KiB
C#
Raw Normal View History

2020-06-24 20:11:38 +08:00
// 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.
2022-06-17 15:37:17 +08:00
#nullable disable
2020-06-24 20:11:38 +08:00
using osu.Framework.Allocation;
using osu.Framework.Graphics;
2022-07-29 21:33:34 +08:00
using osu.Framework.Graphics.Rendering;
2020-06-24 20:11:38 +08:00
using osu.Framework.Graphics.Shaders;
using osu.Framework.Graphics.Sprites;
namespace osu.Game.Graphics.Sprites
{
2020-07-23 04:10:59 +08:00
public class LogoAnimation : Sprite
2020-06-24 20:11:38 +08:00
{
[BackgroundDependencyLoader]
2022-01-15 08:06:39 +08:00
private void load(ShaderManager shaders)
2020-06-24 20:11:38 +08:00
{
2020-07-23 04:10:59 +08:00
TextureShader = shaders.Load(VertexShaderDescriptor.TEXTURE_2, @"LogoAnimation");
RoundedTextureShader = shaders.Load(VertexShaderDescriptor.TEXTURE_2, @"LogoAnimation"); // Masking isn't supported for now
2020-06-24 20:11:38 +08:00
}
private float animationProgress;
public float AnimationProgress
{
get => animationProgress;
set
{
if (animationProgress == value) return;
animationProgress = value;
Invalidate(Invalidation.DrawInfo);
}
}
public override bool IsPresent => true;
2020-07-23 04:10:59 +08:00
protected override DrawNode CreateDrawNode() => new LogoAnimationDrawNode(this);
2020-06-24 20:11:38 +08:00
2020-07-23 04:10:59 +08:00
private class LogoAnimationDrawNode : SpriteDrawNode
2020-06-24 20:11:38 +08:00
{
2020-07-23 04:10:59 +08:00
private LogoAnimation source => (LogoAnimation)Source;
2020-06-24 20:11:38 +08:00
private float progress;
2020-07-23 04:10:59 +08:00
public LogoAnimationDrawNode(LogoAnimation source)
2020-06-24 20:11:38 +08:00
: base(source)
{
}
public override void ApplyState()
{
base.ApplyState();
2020-06-25 06:59:12 +08:00
progress = source.animationProgress;
2020-06-24 20:11:38 +08:00
}
2022-07-29 21:33:34 +08:00
protected override void Blit(IRenderer renderer)
2020-06-24 20:11:38 +08:00
{
GetAppropriateShader(renderer).GetUniform<float>("progress").UpdateValue(ref progress);
2020-06-24 20:11:38 +08:00
2022-07-29 21:33:34 +08:00
base.Blit(renderer);
2020-06-24 20:11:38 +08:00
}
protected override bool CanDrawOpaqueInterior => false;
}
}
}