1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-16 18:27:31 +08:00
osu-lazer/osu.Game/Screens/Play/HUD/ArgonHealthDisplayParts/ArgonHealthDisplayBackground.cs

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

72 lines
2.4 KiB
C#
Raw Normal View History

2024-01-11 19:55:04 +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.Runtime.InteropServices;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Rendering;
using osu.Framework.Graphics.Shaders;
using osu.Framework.Graphics.Shaders.Types;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.Sprites;
using osuTK;
namespace osu.Game.Screens.Play.HUD.ArgonHealthDisplayParts
{
public partial class ArgonHealthDisplayBackground : Box
{
[BackgroundDependencyLoader]
private void load(ShaderManager shaders)
{
TextureShader = shaders.Load(VertexShaderDescriptor.TEXTURE_2, "ArgonBarPathBackground");
}
protected override DrawNode CreateDrawNode() => new ArgonBarPathDrawNode(this);
private class ArgonBarPathDrawNode : SpriteDrawNode
{
protected new ArgonHealthDisplayBackground Source => (ArgonHealthDisplayBackground)base.Source;
2024-01-16 13:17:21 +08:00
private IUniformBuffer<ArgonBarPathBackgroundParameters>? parametersBuffer;
2024-01-11 19:55:04 +08:00
public ArgonBarPathDrawNode(ArgonHealthDisplayBackground source)
: base(source)
{
}
private Vector2 size;
public override void ApplyState()
{
base.ApplyState();
size = Source.DrawSize;
}
protected override void BindUniformResources(IShader shader, IRenderer renderer)
{
base.BindUniformResources(shader, renderer);
parametersBuffer ??= renderer.CreateUniformBuffer<ArgonBarPathBackgroundParameters>();
2024-01-16 13:17:21 +08:00
parametersBuffer.Data = new ArgonBarPathBackgroundParameters { Size = size };
2024-01-11 19:55:04 +08:00
shader.BindUniformBlock("m_ArgonBarPathBackgroundParameters", parametersBuffer);
}
protected override bool CanDrawOpaqueInterior => false;
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
parametersBuffer?.Dispose();
}
[StructLayout(LayoutKind.Sequential, Pack = 1)]
private record struct ArgonBarPathBackgroundParameters
{
public UniformVector2 Size;
2024-01-12 20:30:16 +08:00
private readonly UniformPadding8 pad;
2024-01-11 19:55:04 +08:00
}
}
}
}