Improve paper stamping experience (#17135)

This commit is contained in:
eoineoineoin
2023-08-13 19:28:10 +01:00
committed by GitHub
parent ae2dcc8aba
commit 4ccc8a04be
28 changed files with 629 additions and 202 deletions

View File

@@ -1,23 +1,59 @@
using System.Numerics;
using Content.Shared.Paper;
using Robust.Client.AutoGenerated;
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Utility;
using Robust.Shared.Prototypes;
namespace Content.Client.Paper.UI
namespace Content.Client.Paper.UI;
[GenerateTypedNameReferences]
public sealed partial class StampWidget : PanelContainer
{
[GenerateTypedNameReferences]
public sealed partial class StampWidget : Container
{
public string? Stamper {
get => StampedByLabel.Text;
set => StampedByLabel.Text = value;
}
private StyleBoxTexture _borderTexture;
private ShaderInstance? _stampShader;
public StampWidget()
{
RobustXamlLoader.Load(this);
public float Orientation
{
get => StampedByLabel.Orientation;
set => StampedByLabel.Orientation = value;
}
public StampDisplayInfo StampInfo {
set {
StampedByLabel.Text = Loc.GetString(value.StampedName);
StampedByLabel.FontColorOverride = value.StampedColor;
ModulateSelfOverride = value.StampedColor;
}
}
public StampWidget()
{
RobustXamlLoader.Load(this);
var resCache = IoCManager.Resolve<IResourceCache>();
var borderImage = resCache.GetResource<TextureResource>(
"/Textures/Interface/Paper/paper_stamp_border.svg.96dpi.png");
_borderTexture = new StyleBoxTexture {
Texture = borderImage,
};
_borderTexture.SetPatchMargin(StyleBoxTexture.Margin.All, 7.0f);
PanelOverride = _borderTexture;
var prototypes = IoCManager.Resolve<IPrototypeManager>();
_stampShader = prototypes.Index<ShaderPrototype>("PaperStamp").InstanceUnique();
}
protected override void Draw(DrawingHandleScreen handle)
{
_stampShader?.SetParameter("objCoord", GlobalPosition * UIScale * new Vector2(1, -1));
handle.UseShader(_stampShader);
handle.SetTransform(GlobalPosition * UIScale, Orientation, Vector2.One);
base.Draw(handle);
// Restore a sane transform+shader
handle.SetTransform(Matrix3.Identity);
handle.UseShader(null);
}
}