Skip to content

Commit

Permalink
Добавил возможность написать моноширинным подчерком хе-хе
Browse files Browse the repository at this point in the history
  • Loading branch information
Tymur Valiiev authored and Mirokko committed Oct 15, 2024
1 parent d3684f5 commit 166c9b8
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
38 changes: 38 additions & 0 deletions Content.Client/ADT/UserInterface/RichText/MonospaceTag.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System.Linq;
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface.RichText;
using Robust.Shared.IoC;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;

namespace Content.Client.ADT.UserInterface.RichText;

public sealed class MonospaceTag : IMarkupTag
{
public const string MonospaceFont = "Monospace";

[Dependency] private readonly IResourceCache _resourceCache = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;

public string Name => "mono";

/// <inheritdoc/>
public void PushDrawContext(MarkupNode node, MarkupDrawingContext context)
{
var font = FontTag.CreateFont(
context.Font,
node,
_resourceCache,
_prototypeManager,
MonospaceFont
);
context.Font.Push(font);
}

/// <inheritdoc/>
public void PopDrawContext(MarkupNode node, MarkupDrawingContext context)
{
context.Font.Pop();
}
}
4 changes: 3 additions & 1 deletion Content.Client/Paper/UI/PaperWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Robust.Shared.Utility;
using Robust.Client.UserInterface.RichText;
using Robust.Shared.Input;
using Content.Client.ADT.UserInterface.RichText;

namespace Content.Client.Paper.UI
{
Expand Down Expand Up @@ -43,7 +44,8 @@ public sealed partial class PaperWindow : BaseWindow
typeof(BulletTag),
typeof(ColorTag),
typeof(HeadingTag),
typeof(ItalicTag)
typeof(ItalicTag),
typeof(MonospaceTag),
};

public event Action<string>? OnSaved;
Expand Down

0 comments on commit 166c9b8

Please sign in to comment.