Files
wwdpublic/Content.Client/Guidebook/Richtext/Box.cs
John Willis d83af8a3f8 [Port] Port Guidebook Tables From Wizden PR #28484 (#1427)
# Description
This ports the Guidebook Tables to allow \<Table\> and \<ColorBox\>
embeds in the Guidebook.
This just adds extra XML tags to use in rich-text.

---

# TODO
- [x] Cherry-Pick the PR.
- [x] Tested to make sure it works. It does actively work.

---

# Media
<details><summary><h3>Guidebook Screenshot</h3></summary>
<p>

![image](https://github.com/user-attachments/assets/289e4c72-dcef-4489-b89e-5a2d6367124f)
</p>
</details>

NOTE: This screenshot was taken in the dev-environment. I just
copy-pasted my SOP for Alert Levels to check it, since it uses both the
\<Table\> and \<ColorBox\> identifiers.

---

# Changelog
🆑
- add: Added <Table> and <ColorBox> identifiers. Go wild in SOP!

Co-authored-by: Nemanja <98561806+EmoGarbage404@users.noreply.github.com>
(cherry picked from commit 75bb8d3728441cd7ea57341ba020c80575f35bd9)
2025-01-14 01:22:44 +03:00

33 lines
1.0 KiB
C#

using System.Diagnostics.CodeAnalysis;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
namespace Content.Client.Guidebook.Richtext;
public sealed class Box : BoxContainer, IDocumentTag
{
public bool TryParseTag(Dictionary<string, string> args, [NotNullWhen(true)] out Control? control)
{
HorizontalExpand = true;
control = this;
if (args.TryGetValue("Margin", out var margin))
Margin = new Thickness(float.Parse(margin));
if (args.TryGetValue("Orientation", out var orientation))
Orientation = Enum.Parse<LayoutOrientation>(orientation);
else
Orientation = LayoutOrientation.Horizontal;
if (args.TryGetValue("HorizontalAlignment", out var halign))
HorizontalAlignment = Enum.Parse<HAlignment>(halign);
else
HorizontalAlignment = HAlignment.Center;
if (args.TryGetValue("VerticalAlignment", out var valign))
VerticalAlignment = Enum.Parse<VAlignment>(valign);
return true;
}
}