diff --git a/Content.Client/Paper/UI/PaperVisualsComponent.cs b/Content.Client/Paper/UI/PaperVisualsComponent.cs index 4eda1395e8..9467af2544 100644 --- a/Content.Client/Paper/UI/PaperVisualsComponent.cs +++ b/Content.Client/Paper/UI/PaperVisualsComponent.cs @@ -88,7 +88,7 @@ public sealed class PaperVisualsComponent : Component /// Modulate the style's font by this color /// [DataField("fontAccentColor")] - public Color FontAccentColor = new Color(0x25, 0x25, 0x2a); + public Color FontAccentColor = new Color(223, 223, 213); /// /// This can enforce that your paper has a limited area to write in. diff --git a/Content.Client/Paper/UI/PaperWindow.xaml.cs b/Content.Client/Paper/UI/PaperWindow.xaml.cs index ca1e6e9bf1..c3192a495d 100644 --- a/Content.Client/Paper/UI/PaperWindow.xaml.cs +++ b/Content.Client/Paper/UI/PaperWindow.xaml.cs @@ -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); + // // Size of resize handles around the paper private const int DRAG_MARGIN_SIZE = 16; @@ -27,14 +30,23 @@ namespace Content.Client.Paper.UI // If paper limits the size in one or both axes, it'll affect whether // we're able to resize this UI or not. Default to everything enabled: - private DragMode _allowedResizeModes = ~DragMode.None; + 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; diff --git a/Content.Server/Paper/PaperSystem.cs b/Content.Server/Paper/PaperSystem.cs index 594d4446fc..e3c4e4091b 100644 --- a/Content.Server/Paper/PaperSystem.cs +++ b/Content.Server/Paper/PaperSystem.cs @@ -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(uid, out var appearance)) _appearance.SetData(uid, PaperVisuals.Status, PaperStatus.Written, appearance); diff --git a/Resources/Locale/en-US/guidebook/guides.ftl b/Resources/Locale/en-US/guidebook/guides.ftl index f509b3a002..a43b1e6b74 100644 --- a/Resources/Locale/en-US/guidebook/guides.ftl +++ b/Resources/Locale/en-US/guidebook/guides.ftl @@ -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 diff --git a/Resources/Prototypes/Guidebook/ss14.yml b/Resources/Prototypes/Guidebook/ss14.yml index 7eca9bf47f..9d4cd4bce4 100644 --- a/Resources/Prototypes/Guidebook/ss14.yml +++ b/Resources/Prototypes/Guidebook/ss14.yml @@ -8,3 +8,9 @@ - Survival - Chemicals - Antagonists + - Writing + +- type: guideEntry + id: Writing + name: guide-entry-writing + text: "/ServerInfo/Guidebook/Writing.xml" diff --git a/Resources/Prototypes/fonts.yml b/Resources/Prototypes/fonts.yml index cc943aab85..c883df514c 100644 --- a/Resources/Prototypes/fonts.yml +++ b/Resources/Prototypes/fonts.yml @@ -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 diff --git a/Resources/ServerInfo/Guidebook/Writing.xml b/Resources/ServerInfo/Guidebook/Writing.xml new file mode 100644 index 0000000000..d47775fa97 --- /dev/null +++ b/Resources/ServerInfo/Guidebook/Writing.xml @@ -0,0 +1,22 @@ + +# 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] + +