1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-19 07:43:20 +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.
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;
using osu.Framework.Graphics.Textures;
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]
private void load(ShaderManager shaders, TextureStore textures)
{
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
}
protected override void Blit(Action<TexturedVertex2D> vertexAction)
{
Shader.GetUniform<float>("progress").UpdateValue(ref progress);
base.Blit(vertexAction);
}
protected override bool CanDrawOpaqueInterior => false;
}
}
}