1
0

RichTextLabelExt.cs 914 B

12345678910111213141516171819202122232425262728293031
  1. using Robust.Client.UserInterface.Controls;
  2. using Robust.Shared.Utility;
  3. namespace Content.Client.Message;
  4. public static class RichTextLabelExt
  5. {
  6. /// <summary>
  7. /// Sets the labels markup.
  8. /// </summary>
  9. /// <remarks>
  10. /// Invalid markup will cause exceptions to be thrown. Don't use this for user input!
  11. /// </remarks>
  12. public static RichTextLabel SetMarkup(this RichTextLabel label, string markup)
  13. {
  14. label.SetMessage(FormattedMessage.FromMarkupOrThrow(markup));
  15. return label;
  16. }
  17. /// <summary>
  18. /// Sets the labels markup.<br/>
  19. /// Uses <c>FormatedMessage.FromMarkupPermissive</c> which treats invalid markup as text.
  20. /// </summary>
  21. public static RichTextLabel SetMarkupPermissive(this RichTextLabel label, string markup)
  22. {
  23. label.SetMessage(FormattedMessage.FromMarkupPermissive(markup));
  24. return label;
  25. }
  26. }