Files
tbd-station-14/Content.Client/Overlays/BlackAndWhiteOverlay.cs
Tayrtahn 9186b65b14 Validate ShaderPrototype IDs (#38728)
* Convert all shader prototype string literals to protoids in overlays

* Convert more shader prototype literal strings to protoids

* Convert ValidatePrototypeId to ProtoId

* Later
2025-07-03 18:11:31 -07:00

36 lines
1.1 KiB
C#

using Robust.Client.Graphics;
using Robust.Shared.Enums;
using Robust.Shared.Prototypes;
namespace Content.Client.Overlays;
public sealed partial class BlackAndWhiteOverlay : Overlay
{
private static readonly ProtoId<ShaderPrototype> Shader = "GreyscaleFullscreen";
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public override OverlaySpace Space => OverlaySpace.WorldSpace;
public override bool RequestScreenTexture => true;
private readonly ShaderInstance _greyscaleShader;
public BlackAndWhiteOverlay()
{
IoCManager.InjectDependencies(this);
_greyscaleShader = _prototypeManager.Index(Shader).InstanceUnique();
ZIndex = 10; // draw this over the DamageOverlay, RainbowOverlay etc.
}
protected override void Draw(in OverlayDrawArgs args)
{
if (ScreenTexture == null)
return;
var handle = args.WorldHandle;
_greyscaleShader.SetParameter("SCREEN_TEXTURE", ScreenTexture);
handle.UseShader(_greyscaleShader);
handle.DrawRect(args.WorldBounds, Color.White);
handle.UseShader(null);
}
}