osu/osu.Game/Graphics/Sprites/LogoAnimation.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

71 lines
2.0 KiB
C#
Raw Normal View History

2020-06-24 12:11:38 +00: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 07:37:17 +00:00
#nullable disable
2020-06-24 12:11:38 +00:00
using System;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.OpenGL.Vertices;
using osu.Framework.Graphics.Shaders;
using osu.Framework.Graphics.Sprites;
namespace osu.Game.Graphics.Sprites
{
2020-07-22 20:10:59 +00:00
public class LogoAnimation : Sprite
2020-06-24 12:11:38 +00:00
{
[BackgroundDependencyLoader]
2022-01-15 00:06:39 +00:00
private void load(ShaderManager shaders)
2020-06-24 12:11:38 +00:00
{
2020-07-22 20:10:59 +00:00
TextureShader = shaders.Load(VertexShaderDescriptor.TEXTURE_2, @"LogoAnimation");
RoundedTextureShader = shaders.Load(VertexShaderDescriptor.TEXTURE_2, @"LogoAnimation"); // Masking isn't supported for now
2020-06-24 12:11:38 +00: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-22 20:10:59 +00:00
protected override DrawNode CreateDrawNode() => new LogoAnimationDrawNode(this);
2020-06-24 12:11:38 +00:00
2020-07-22 20:10:59 +00:00
private class LogoAnimationDrawNode : SpriteDrawNode
2020-06-24 12:11:38 +00:00
{
2020-07-22 20:10:59 +00:00
private LogoAnimation source => (LogoAnimation)Source;
2020-06-24 12:11:38 +00:00
private float progress;
2020-07-22 20:10:59 +00:00
public LogoAnimationDrawNode(LogoAnimation source)
2020-06-24 12:11:38 +00:00
: base(source)
{
}
public override void ApplyState()
{
base.ApplyState();
2020-06-24 22:59:12 +00:00
progress = source.animationProgress;
2020-06-24 12:11:38 +00:00
}
protected override void Blit(Action<TexturedVertex2D> vertexAction)
{
Shader.GetUniform<float>("progress").UpdateValue(ref progress);
base.Blit(vertexAction);
}
protected override bool CanDrawOpaqueInterior => false;
}
}
}