mirror of
https://github.com/ppy/osu.git
synced 2024-11-14 15:57:24 +08:00
Merge pull request #26479 from EVAST9919/argon-health-rework
Rework `ArgonHealthDisplay` to use shaders
This commit is contained in:
commit
24a06e1d65
@ -2,23 +2,19 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Caching;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Lines;
|
||||
using osu.Framework.Layout;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Screens.Play.HUD.ArgonHealthDisplayParts;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
@ -40,16 +36,14 @@ namespace osu.Game.Screens.Play.HUD
|
||||
[SettingSource("Use relative size")]
|
||||
public BindableBool UseRelativeSize { get; } = new BindableBool(true);
|
||||
|
||||
private BarPath mainBar = null!;
|
||||
private ArgonHealthDisplayBar mainBar = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Used to show a glow at the end of the main bar, or red "damage" area when missing.
|
||||
/// </summary>
|
||||
private BarPath glowBar = null!;
|
||||
private ArgonHealthDisplayBar glowBar = null!;
|
||||
|
||||
private BackgroundPath background = null!;
|
||||
|
||||
private SliderPath barPath = null!;
|
||||
private Container content = null!;
|
||||
|
||||
private static readonly Colour4 main_bar_colour = Colour4.White;
|
||||
private static readonly Colour4 main_bar_glow_colour = Color4Extensions.FromHex("#7ED7FD").Opacity(0.5f);
|
||||
@ -58,23 +52,17 @@ namespace osu.Game.Screens.Play.HUD
|
||||
|
||||
private bool displayingMiss => resetMissBarDelegate != null;
|
||||
|
||||
private readonly List<Vector2> vertices = new List<Vector2>();
|
||||
|
||||
private double glowBarValue;
|
||||
|
||||
private double healthBarValue;
|
||||
|
||||
public const float MAIN_PATH_RADIUS = 10f;
|
||||
|
||||
private const float curve_start_offset = 70;
|
||||
private const float curve_end_offset = 40;
|
||||
private const float padding = MAIN_PATH_RADIUS * 2;
|
||||
private const float curve_smoothness = 10;
|
||||
private const float glow_path_radius = 40f;
|
||||
private const float main_path_glow_portion = 0.6f;
|
||||
|
||||
private readonly LayoutValue drawSizeLayout = new LayoutValue(Invalidation.DrawSize);
|
||||
|
||||
private readonly Cached pathVerticesCache = new Cached();
|
||||
|
||||
public ArgonHealthDisplay()
|
||||
{
|
||||
AddLayout(drawSizeLayout);
|
||||
@ -92,36 +80,39 @@ namespace osu.Game.Screens.Play.HUD
|
||||
{
|
||||
AutoSizeAxes = Axes.Y;
|
||||
|
||||
InternalChild = new Container
|
||||
InternalChild = content = new Container
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Children = new Drawable[]
|
||||
{
|
||||
background = new BackgroundPath
|
||||
new ArgonHealthDisplayBackground
|
||||
{
|
||||
PathRadius = MAIN_PATH_RADIUS,
|
||||
RelativeSizeAxes = Axes.Both
|
||||
},
|
||||
glowBar = new BarPath
|
||||
new Container
|
||||
{
|
||||
BarColour = Color4.White,
|
||||
GlowColour = main_bar_glow_colour,
|
||||
Blending = BlendingParameters.Additive,
|
||||
Colour = ColourInfo.GradientHorizontal(Color4.White.Opacity(0.8f), Color4.White),
|
||||
PathRadius = 40f,
|
||||
// Kinda hacky, but results in correct positioning with increased path radius.
|
||||
Margin = new MarginPadding(-30f),
|
||||
GlowPortion = 0.9f,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
// since we are using bigger path radius we need to expand the draw area outwards to preserve the curve placement
|
||||
Padding = new MarginPadding(MAIN_PATH_RADIUS - glow_path_radius),
|
||||
Child = glowBar = new ArgonHealthDisplayBar
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
BarColour = Color4.White,
|
||||
GlowColour = main_bar_glow_colour,
|
||||
Blending = BlendingParameters.Additive,
|
||||
Colour = ColourInfo.GradientHorizontal(Color4.White.Opacity(0.8f), Color4.White),
|
||||
PathRadius = glow_path_radius,
|
||||
GlowPortion = (glow_path_radius - MAIN_PATH_RADIUS * (1f - main_path_glow_portion)) / glow_path_radius,
|
||||
}
|
||||
},
|
||||
mainBar = new BarPath
|
||||
mainBar = new ArgonHealthDisplayBar
|
||||
{
|
||||
AutoSizeAxes = Axes.None,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Blending = BlendingParameters.Additive,
|
||||
BarColour = main_bar_colour,
|
||||
GlowColour = main_bar_glow_colour,
|
||||
PathRadius = MAIN_PATH_RADIUS,
|
||||
GlowPortion = 0.6f,
|
||||
},
|
||||
GlowPortion = main_path_glow_portion
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -142,7 +133,7 @@ namespace osu.Game.Screens.Play.HUD
|
||||
UseRelativeSize.BindValueChanged(v => RelativeSizeAxes = v.NewValue ? Axes.X : Axes.None, true);
|
||||
Width = previousWidth;
|
||||
|
||||
BarHeight.BindValueChanged(_ => updatePath(), true);
|
||||
BarHeight.BindValueChanged(_ => updateContentSize(), true);
|
||||
}
|
||||
|
||||
private void onNewJudgement(JudgementResult result) => pendingMissAnimation |= !result.IsHit;
|
||||
@ -153,7 +144,7 @@ namespace osu.Game.Screens.Play.HUD
|
||||
|
||||
if (!drawSizeLayout.IsValid)
|
||||
{
|
||||
updatePath();
|
||||
updateContentSize();
|
||||
drawSizeLayout.Validate();
|
||||
}
|
||||
|
||||
@ -164,7 +155,7 @@ namespace osu.Game.Screens.Play.HUD
|
||||
mainBar.Alpha = (float)Interpolation.DampContinuously(mainBar.Alpha, Current.Value > 0 ? 1 : 0, 40, Time.Elapsed);
|
||||
glowBar.Alpha = (float)Interpolation.DampContinuously(glowBar.Alpha, glowBarValue > 0 ? 1 : 0, 40, Time.Elapsed);
|
||||
|
||||
updatePathVertices();
|
||||
updatePathProgress();
|
||||
}
|
||||
|
||||
protected override void HealthChanged(bool increase)
|
||||
@ -194,10 +185,9 @@ namespace osu.Game.Screens.Play.HUD
|
||||
|
||||
if (!displayingMiss)
|
||||
{
|
||||
// TODO: REMOVE THIS. It's recreating textures.
|
||||
glowBar.TransformTo(nameof(BarPath.GlowColour), Colour4.White, 30, Easing.OutQuint)
|
||||
glowBar.TransformTo(nameof(ArgonHealthDisplayBar.GlowColour), Colour4.White, 30, Easing.OutQuint)
|
||||
.Then()
|
||||
.TransformTo(nameof(BarPath.GlowColour), main_bar_glow_colour, 300, Easing.OutQuint);
|
||||
.TransformTo(nameof(ArgonHealthDisplayBar.GlowColour), main_bar_glow_colour, 300, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
|
||||
@ -212,13 +202,11 @@ namespace osu.Game.Screens.Play.HUD
|
||||
finishMissDisplay();
|
||||
}, out resetMissBarDelegate);
|
||||
|
||||
// TODO: REMOVE THIS. It's recreating textures.
|
||||
glowBar.TransformTo(nameof(BarPath.BarColour), new Colour4(255, 147, 147, 255), 100, Easing.OutQuint).Then()
|
||||
.TransformTo(nameof(BarPath.BarColour), new Colour4(255, 93, 93, 255), 800, Easing.OutQuint);
|
||||
glowBar.TransformTo(nameof(ArgonHealthDisplayBar.BarColour), new Colour4(255, 147, 147, 255), 100, Easing.OutQuint).Then()
|
||||
.TransformTo(nameof(ArgonHealthDisplayBar.BarColour), new Colour4(255, 93, 93, 255), 800, Easing.OutQuint);
|
||||
|
||||
// TODO: REMOVE THIS. It's recreating textures.
|
||||
glowBar.TransformTo(nameof(BarPath.GlowColour), new Colour4(253, 0, 0, 255).Lighten(0.2f))
|
||||
.TransformTo(nameof(BarPath.GlowColour), new Colour4(253, 0, 0, 255), 800, Easing.OutQuint);
|
||||
glowBar.TransformTo(nameof(ArgonHealthDisplayBar.GlowColour), new Colour4(253, 0, 0, 255).Lighten(0.2f))
|
||||
.TransformTo(nameof(ArgonHealthDisplayBar.GlowColour), new Colour4(253, 0, 0, 255), 800, Easing.OutQuint);
|
||||
}
|
||||
|
||||
private void finishMissDisplay()
|
||||
@ -228,53 +216,22 @@ namespace osu.Game.Screens.Play.HUD
|
||||
|
||||
if (Current.Value > 0)
|
||||
{
|
||||
// TODO: REMOVE THIS. It's recreating textures.
|
||||
glowBar.TransformTo(nameof(BarPath.BarColour), main_bar_colour, 300, Easing.In);
|
||||
glowBar.TransformTo(nameof(BarPath.GlowColour), main_bar_glow_colour, 300, Easing.In);
|
||||
glowBar.TransformTo(nameof(ArgonHealthDisplayBar.BarColour), main_bar_colour, 300, Easing.In);
|
||||
glowBar.TransformTo(nameof(ArgonHealthDisplayBar.GlowColour), main_bar_glow_colour, 300, Easing.In);
|
||||
}
|
||||
|
||||
resetMissBarDelegate?.Cancel();
|
||||
resetMissBarDelegate = null;
|
||||
}
|
||||
|
||||
private void updatePath()
|
||||
private void updateContentSize()
|
||||
{
|
||||
float usableWidth = DrawWidth - padding;
|
||||
|
||||
if (usableWidth < 0) enforceMinimumWidth();
|
||||
|
||||
// the display starts curving at `curve_start_offset` units from the right and ends curving at `curve_end_offset`.
|
||||
// to ensure that the curve is symmetric when it starts being narrow enough, add a `curve_end_offset` to the left side too.
|
||||
const float rescale_cutoff = curve_start_offset + curve_end_offset;
|
||||
|
||||
float barLength = Math.Max(DrawWidth - padding, rescale_cutoff);
|
||||
float curveStart = barLength - curve_start_offset;
|
||||
float curveEnd = barLength - curve_end_offset;
|
||||
|
||||
Vector2 diagonalDir = (new Vector2(curveEnd, BarHeight.Value) - new Vector2(curveStart, 0)).Normalized();
|
||||
|
||||
barPath = new SliderPath(new[]
|
||||
{
|
||||
new PathControlPoint(new Vector2(0, 0), PathType.LINEAR),
|
||||
new PathControlPoint(new Vector2(curveStart - curve_smoothness, 0), PathType.BEZIER),
|
||||
new PathControlPoint(new Vector2(curveStart, 0)),
|
||||
new PathControlPoint(new Vector2(curveStart, 0) + diagonalDir * curve_smoothness, PathType.LINEAR),
|
||||
new PathControlPoint(new Vector2(curveEnd, BarHeight.Value) - diagonalDir * curve_smoothness, PathType.BEZIER),
|
||||
new PathControlPoint(new Vector2(curveEnd, BarHeight.Value)),
|
||||
new PathControlPoint(new Vector2(curveEnd + curve_smoothness, BarHeight.Value), PathType.LINEAR),
|
||||
new PathControlPoint(new Vector2(barLength, BarHeight.Value)),
|
||||
});
|
||||
|
||||
if (DrawWidth - padding < rescale_cutoff)
|
||||
rescalePathProportionally();
|
||||
|
||||
barPath.GetPathToProgress(vertices, 0.0, 1.0);
|
||||
|
||||
background.Vertices = vertices;
|
||||
mainBar.Vertices = vertices;
|
||||
glowBar.Vertices = vertices;
|
||||
|
||||
updatePathVertices();
|
||||
content.Size = new Vector2(DrawWidth, BarHeight.Value + padding);
|
||||
updatePathProgress();
|
||||
|
||||
void enforceMinimumWidth()
|
||||
{
|
||||
@ -287,35 +244,12 @@ namespace osu.Game.Screens.Play.HUD
|
||||
|
||||
RelativeSizeAxes = relativeAxes;
|
||||
}
|
||||
|
||||
void rescalePathProportionally()
|
||||
{
|
||||
foreach (var point in barPath.ControlPoints)
|
||||
point.Position = new Vector2(point.Position.X / barLength * (DrawWidth - padding), point.Position.Y);
|
||||
}
|
||||
}
|
||||
|
||||
private void updatePathVertices()
|
||||
private void updatePathProgress()
|
||||
{
|
||||
barPath.GetPathToProgress(vertices, 0.0, healthBarValue);
|
||||
if (vertices.Count == 0) vertices.Add(Vector2.Zero);
|
||||
Vector2 initialVertex = vertices[0];
|
||||
for (int i = 0; i < vertices.Count; i++)
|
||||
vertices[i] -= initialVertex;
|
||||
|
||||
mainBar.Vertices = vertices;
|
||||
mainBar.Position = initialVertex;
|
||||
|
||||
barPath.GetPathToProgress(vertices, healthBarValue, Math.Max(glowBarValue, healthBarValue));
|
||||
if (vertices.Count == 0) vertices.Add(Vector2.Zero);
|
||||
initialVertex = vertices[0];
|
||||
for (int i = 0; i < vertices.Count; i++)
|
||||
vertices[i] -= initialVertex;
|
||||
|
||||
glowBar.Vertices = vertices;
|
||||
glowBar.Position = initialVertex;
|
||||
|
||||
pathVerticesCache.Validate();
|
||||
mainBar.ProgressRange = new Vector2(0f, (float)healthBarValue);
|
||||
glowBar.ProgressRange = new Vector2((float)healthBarValue, (float)Math.Max(glowBarValue, healthBarValue));
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
@ -325,67 +259,5 @@ namespace osu.Game.Screens.Play.HUD
|
||||
if (HealthProcessor.IsNotNull())
|
||||
HealthProcessor.NewJudgement -= onNewJudgement;
|
||||
}
|
||||
|
||||
private partial class BackgroundPath : SmoothPath
|
||||
{
|
||||
private static readonly Color4 colour_white = Color4.White.Opacity(0.8f);
|
||||
private static readonly Color4 colour_black = Color4.Black.Opacity(0.2f);
|
||||
|
||||
protected override Color4 ColourAt(float position)
|
||||
{
|
||||
if (position <= 0.16f)
|
||||
return colour_white;
|
||||
|
||||
return Interpolation.ValueAt(position,
|
||||
colour_white,
|
||||
colour_black,
|
||||
-0.5f, 1f, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
|
||||
private partial class BarPath : SmoothPath
|
||||
{
|
||||
private Colour4 barColour;
|
||||
|
||||
public Colour4 BarColour
|
||||
{
|
||||
get => barColour;
|
||||
set
|
||||
{
|
||||
if (barColour == value)
|
||||
return;
|
||||
|
||||
barColour = value;
|
||||
InvalidateTexture();
|
||||
}
|
||||
}
|
||||
|
||||
private Colour4 glowColour;
|
||||
|
||||
public Colour4 GlowColour
|
||||
{
|
||||
get => glowColour;
|
||||
set
|
||||
{
|
||||
if (glowColour == value)
|
||||
return;
|
||||
|
||||
glowColour = value;
|
||||
InvalidateTexture();
|
||||
}
|
||||
}
|
||||
|
||||
public float GlowPortion { get; init; }
|
||||
|
||||
private static readonly Colour4 transparent_black = Colour4.Black.Opacity(0.0f);
|
||||
|
||||
protected override Color4 ColourAt(float position)
|
||||
{
|
||||
if (position >= GlowPortion)
|
||||
return BarColour;
|
||||
|
||||
return Interpolation.ValueAt(position, transparent_black, GlowColour, 0.0, GlowPortion, Easing.InQuint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,71 @@
|
||||
// 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;
|
||||
|
||||
private IUniformBuffer<ArgonBarPathBackgroundParameters>? parametersBuffer;
|
||||
|
||||
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>();
|
||||
parametersBuffer.Data = new ArgonBarPathBackgroundParameters { Size = size };
|
||||
|
||||
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;
|
||||
private readonly UniformPadding8 pad;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,181 @@
|
||||
// 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 System.Runtime.InteropServices;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
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;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Play.HUD.ArgonHealthDisplayParts
|
||||
{
|
||||
public partial class ArgonHealthDisplayBar : Box
|
||||
{
|
||||
private Vector2 progressRange = new Vector2(0f, 1f);
|
||||
|
||||
public Vector2 ProgressRange
|
||||
{
|
||||
get => progressRange;
|
||||
set
|
||||
{
|
||||
if (progressRange == value)
|
||||
return;
|
||||
|
||||
progressRange = value;
|
||||
Invalidate(Invalidation.DrawNode);
|
||||
}
|
||||
}
|
||||
|
||||
private float radius = 10f;
|
||||
|
||||
public float PathRadius
|
||||
{
|
||||
get => radius;
|
||||
set
|
||||
{
|
||||
if (radius == value)
|
||||
return;
|
||||
|
||||
radius = value;
|
||||
Invalidate(Invalidation.DrawNode);
|
||||
}
|
||||
}
|
||||
|
||||
private float glowPortion;
|
||||
|
||||
public float GlowPortion
|
||||
{
|
||||
get => glowPortion;
|
||||
set
|
||||
{
|
||||
if (glowPortion == value)
|
||||
return;
|
||||
|
||||
glowPortion = value;
|
||||
Invalidate(Invalidation.DrawNode);
|
||||
}
|
||||
}
|
||||
|
||||
private Colour4 barColour = Color4.White;
|
||||
|
||||
public Colour4 BarColour
|
||||
{
|
||||
get => barColour;
|
||||
set
|
||||
{
|
||||
if (barColour == value)
|
||||
return;
|
||||
|
||||
barColour = value;
|
||||
Invalidate(Invalidation.DrawNode);
|
||||
}
|
||||
}
|
||||
|
||||
private Colour4 glowColour = Color4.White.Opacity(0);
|
||||
|
||||
public Colour4 GlowColour
|
||||
{
|
||||
get => glowColour;
|
||||
set
|
||||
{
|
||||
if (glowColour == value)
|
||||
return;
|
||||
|
||||
glowColour = value;
|
||||
Invalidate(Invalidation.DrawNode);
|
||||
}
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(ShaderManager shaders)
|
||||
{
|
||||
TextureShader = shaders.Load(VertexShaderDescriptor.TEXTURE_2, "ArgonBarPath");
|
||||
}
|
||||
|
||||
protected override DrawNode CreateDrawNode() => new ArgonBarPathDrawNode(this);
|
||||
|
||||
private class ArgonBarPathDrawNode : SpriteDrawNode
|
||||
{
|
||||
protected new ArgonHealthDisplayBar Source => (ArgonHealthDisplayBar)base.Source;
|
||||
|
||||
private IUniformBuffer<ArgonBarPathParameters>? parametersBuffer;
|
||||
|
||||
public ArgonBarPathDrawNode(ArgonHealthDisplayBar source)
|
||||
: base(source)
|
||||
{
|
||||
}
|
||||
|
||||
private Vector2 size;
|
||||
private Vector2 progressRange;
|
||||
private float pathRadius;
|
||||
private float glowPortion;
|
||||
private Color4 barColour;
|
||||
private Color4 glowColour;
|
||||
|
||||
public override void ApplyState()
|
||||
{
|
||||
base.ApplyState();
|
||||
|
||||
size = Source.DrawSize;
|
||||
progressRange = new Vector2(Math.Min(Source.progressRange.X, Source.progressRange.Y), Source.progressRange.Y);
|
||||
pathRadius = Source.PathRadius;
|
||||
glowPortion = Source.GlowPortion;
|
||||
barColour = Source.barColour;
|
||||
glowColour = Source.glowColour;
|
||||
}
|
||||
|
||||
protected override void Draw(IRenderer renderer)
|
||||
{
|
||||
if (pathRadius == 0)
|
||||
return;
|
||||
|
||||
base.Draw(renderer);
|
||||
}
|
||||
|
||||
protected override void BindUniformResources(IShader shader, IRenderer renderer)
|
||||
{
|
||||
base.BindUniformResources(shader, renderer);
|
||||
|
||||
parametersBuffer ??= renderer.CreateUniformBuffer<ArgonBarPathParameters>();
|
||||
parametersBuffer.Data = new ArgonBarPathParameters
|
||||
{
|
||||
BarColour = new Vector4(barColour.R, barColour.G, barColour.B, barColour.A),
|
||||
GlowColour = new Vector4(glowColour.R, glowColour.G, glowColour.B, glowColour.A),
|
||||
GlowPortion = glowPortion,
|
||||
Size = size,
|
||||
ProgressRange = progressRange,
|
||||
PathRadius = pathRadius
|
||||
};
|
||||
|
||||
shader.BindUniformBlock("m_ArgonBarPathParameters", 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 ArgonBarPathParameters
|
||||
{
|
||||
public UniformVector4 BarColour;
|
||||
public UniformVector4 GlowColour;
|
||||
public UniformVector2 Size;
|
||||
public UniformVector2 ProgressRange;
|
||||
public UniformFloat PathRadius;
|
||||
public UniformFloat GlowPortion;
|
||||
private readonly UniformPadding8 pad;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -37,7 +37,7 @@
|
||||
</PackageReference>
|
||||
<PackageReference Include="Realm" Version="11.5.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2024.114.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2023.1228.0" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2024.116.0" />
|
||||
<PackageReference Include="Sentry" Version="3.40.0" />
|
||||
<!-- Held back due to 0.34.0 failing AOT compilation on ZstdSharp.dll dependency. -->
|
||||
<PackageReference Include="SharpCompress" Version="0.33.0" />
|
||||
|
Loading…
Reference in New Issue
Block a user