allow richtext on papers + edit premade documents (#18154)
This commit is contained in:
@@ -88,7 +88,7 @@ public sealed class PaperVisualsComponent : Component
|
||||
/// Modulate the style's font by this color
|
||||
/// </summary>
|
||||
[DataField("fontAccentColor")]
|
||||
public Color FontAccentColor = new Color(0x25, 0x25, 0x2a);
|
||||
public Color FontAccentColor = new Color(223, 223, 213);
|
||||
|
||||
/// <summary>
|
||||
/// This can enforce that your paper has a limited area to write in.
|
||||
|
||||
@@ -7,12 +7,15 @@ using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Client.UserInterface.RichText;
|
||||
|
||||
namespace Content.Client.Paper.UI
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class PaperWindow : BaseWindow
|
||||
{
|
||||
private static Color DefaultTextColor = new(25, 25, 25);
|
||||
|
||||
// <summary>
|
||||
// Size of resize handles around the paper
|
||||
private const int DRAG_MARGIN_SIZE = 16;
|
||||
@@ -29,12 +32,21 @@ namespace Content.Client.Paper.UI
|
||||
// we're able to resize this UI or not. Default to everything enabled:
|
||||
private DragMode _allowedResizeModes = ~DragMode.None;
|
||||
|
||||
private readonly Type[] _allowedTags = new Type[] {
|
||||
typeof(BoldItalicTag),
|
||||
typeof(BoldTag),
|
||||
typeof(BulletTag),
|
||||
typeof(ColorTag),
|
||||
typeof(HeadingTag),
|
||||
typeof(ItalicTag)
|
||||
};
|
||||
|
||||
public PaperWindow()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
|
||||
// We can't configure the RichTextLabel contents from xaml, so do it here:
|
||||
BlankPaperIndicator.SetMessage(Loc.GetString("paper-ui-blank-page-message"));
|
||||
BlankPaperIndicator.SetMessage(Loc.GetString("paper-ui-blank-page-message"), null, DefaultTextColor);
|
||||
|
||||
// Hook up the close button:
|
||||
CloseButton.OnPressed += _ => Close();
|
||||
@@ -188,7 +200,10 @@ namespace Content.Client.Paper.UI
|
||||
var msg = new FormattedMessage();
|
||||
msg.AddMarkupPermissive(state.Text);
|
||||
|
||||
if (!wasEditing)
|
||||
// For premade documents, we want to be able to edit them rather than
|
||||
// replace them.
|
||||
var shouldCopyText = 0 == Input.TextLength && 0 != state.Text.Length;
|
||||
if (!wasEditing || shouldCopyText)
|
||||
{
|
||||
// We can get repeated messages with state.Mode == Write if another
|
||||
// player opens the UI for reading. In this case, don't update the
|
||||
@@ -196,14 +211,14 @@ namespace Content.Client.Paper.UI
|
||||
// don't want to lose any text they already input.
|
||||
Input.TextRope = Rope.Leaf.Empty;
|
||||
Input.CursorPosition = new TextEdit.CursorPos();
|
||||
Input.InsertAtCursor(msg.ToString());
|
||||
Input.InsertAtCursor(state.Text);
|
||||
}
|
||||
|
||||
for (var i = 0; i <= state.StampedBy.Count * 3 + 1; i++)
|
||||
{
|
||||
msg.AddMarkupPermissive("\r\n");
|
||||
}
|
||||
WrittenTextLabel.SetMessage(msg);
|
||||
WrittenTextLabel.SetMessage(msg, _allowedTags, DefaultTextColor);
|
||||
|
||||
WrittenTextLabel.Visible = !isEditing && state.Text.Length > 0;
|
||||
BlankPaperIndicator.Visible = !isEditing && state.Text.Length == 0;
|
||||
|
||||
@@ -145,10 +145,8 @@ namespace Content.Server.Paper
|
||||
if (string.IsNullOrEmpty(args.Text))
|
||||
return;
|
||||
|
||||
var text = FormattedMessage.EscapeText(args.Text);
|
||||
|
||||
if (text.Length + paperComp.Content.Length <= paperComp.ContentSize)
|
||||
paperComp.Content = text;
|
||||
if (args.Text.Length + paperComp.Content.Length <= paperComp.ContentSize)
|
||||
paperComp.Content = args.Text;
|
||||
|
||||
if (TryComp<AppearanceComponent>(uid, out var appearance))
|
||||
_appearance.SetData(uid, PaperVisuals.Status, PaperStatus.Written, appearance);
|
||||
|
||||
@@ -48,3 +48,5 @@ guide-entry-nuclear-operatives = Nuclear Operatives
|
||||
guide-entry-traitors = Traitors
|
||||
guide-entry-zombies = Zombies
|
||||
guide-entry-minor-antagonists = Minor Antagonists
|
||||
|
||||
guide-entry-writing = Writing
|
||||
|
||||
@@ -8,3 +8,9 @@
|
||||
- Survival
|
||||
- Chemicals
|
||||
- Antagonists
|
||||
- Writing
|
||||
|
||||
- type: guideEntry
|
||||
id: Writing
|
||||
name: guide-entry-writing
|
||||
text: "/ServerInfo/Guidebook/Writing.xml"
|
||||
|
||||
@@ -10,6 +10,10 @@
|
||||
id: DefaultBold
|
||||
path: /Fonts/NotoSans/NotoSans-Bold.ttf
|
||||
|
||||
- type: font
|
||||
id: DefaultBoldItalic
|
||||
path: /Fonts/NotoSans/NotoSans-BoldItalic.ttf
|
||||
|
||||
- type: font
|
||||
id: NotoSansDisplay
|
||||
path: /Fonts/NotoSansDisplay/NotoSansDisplay-Regular.ttf
|
||||
|
||||
22
Resources/ServerInfo/Guidebook/Writing.xml
Normal file
22
Resources/ServerInfo/Guidebook/Writing.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<Document>
|
||||
# Writing
|
||||
|
||||
Using a pen, you can write on paper or in books. Nanotrasen provides everyone with a spare pen in their PDA.
|
||||
|
||||
## Formatting
|
||||
|
||||
You can use the following sigils:
|
||||
|
||||
- [color=tan]\[color=color\]\[\/color\][/color] — to change the color of the text
|
||||
- [color=tan]\[head=n\]\[\/head\][/color] — where [italic]n[/italic] is the heading level (1 – 3)
|
||||
- [color=tan]\[bullet\/\][/color] — to insert a bullet point (useful for lists)
|
||||
- [color=tan][bold]\[bold\]\[\/bold\][/bold][/color], [color=tan][italic]\[italic\]\[\/italic\][/italic][/color] — for emphasis
|
||||
|
||||
You can combine [bold][italic]bold and italic[/italic][/bold] tags, or use the shortcut [color=tan][bolditalic]\[bolditalic\][/bolditalic][/color].
|
||||
|
||||
Color supports either hexadecimal or most HTML color names. For example:
|
||||
|
||||
- [color=#ff0000]\[color=#ff0000\]\[\/color\][/color]
|
||||
- [color=red]\[color=red\]\[\/color\][/color]
|
||||
|
||||
</Document>
|
||||
Reference in New Issue
Block a user