Enhance paperwork UI (#16006)

This commit is contained in:
Echo
2023-05-06 00:35:22 -07:00
committed by GitHub
parent 77edd7e666
commit 68eb28ac95
5 changed files with 23 additions and 14 deletions

View File

@@ -1,7 +1,7 @@
<paper:PaperWindow xmlns="https://spacestation14.io"
xmlns:paper="clr-namespace:Content.Client.Paper.UI"
MouseFilter="Stop" Resizable="True" MinSize="150 150"
SetSize="300 400"> <!-- Provide some reasonable sizes by default. Can be changed by the component -->
SetSize="510 660"> <!-- Provide some reasonable sizes by default. Can be changed by the component -->
<BoxContainer Name="ContentsRoot" Orientation="Vertical">
<PanelContainer StyleClasses="AngleRect" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="6">
@@ -13,8 +13,7 @@
<BoxContainer Orientation="Vertical" VerticalAlignment="Stretch">
<TextureButton Name="HeaderImage" HorizontalAlignment="Center" VerticalAlignment="Top" MouseFilter="Ignore"/>
<Control Name="TextAlignmentPadding" VerticalAlignment="Top"/>
<RichTextLabel Name="BlankPaperIndicator" StyleClasses="LabelSecondaryColor"
VerticalAlignment="Top" HorizontalAlignment="Center"/>
<RichTextLabel Name="BlankPaperIndicator" StyleClasses="LabelSecondaryColor" VerticalAlignment="Top" HorizontalAlignment="Center"/>
<RichTextLabel StyleClasses="PaperWrittenText" Name="WrittenTextLabel" VerticalAlignment="Top"/>
<PanelContainer Name="InputContainer" StyleClasses="TransparentBorderedWindowPanel" MinHeight="100"
VerticalAlignment="Stretch" VerticalExpand="True" HorizontalExpand="True">

View File

@@ -3,6 +3,7 @@ using Robust.Client.AutoGenerated;
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Utility;
@@ -180,13 +181,19 @@ namespace Content.Client.Paper.UI
InputContainer.Visible = isEditing;
var msg = new FormattedMessage();
// Remove any newlines from the end of the message. There can be a trailing
// new line at the end of user input, and we would like to display the input
// box immediately on the next line.
msg.AddMarkupPermissive(state.Text.TrimEnd('\r', '\n'));
WrittenTextLabel.SetMessage(msg);
WrittenTextLabel.Visible = state.Text.Length > 0;
msg.AddMarkupPermissive(state.Text);
Input.TextRope = Rope.Leaf.Empty;
Input.CursorPosition = new TextEdit.CursorPos();
Input.InsertAtCursor(msg.ToString());
for (var i = 0; i <= state.StampedBy.Count * 3 + 1; i++)
{
msg.AddMarkupPermissive("\r\n");
}
WrittenTextLabel.SetMessage(msg);
WrittenTextLabel.Visible = !isEditing && state.Text.Length > 0;
BlankPaperIndicator.Visible = !isEditing && state.Text.Length == 0;
StampDisplay.RemoveAllChildren();

View File

@@ -11,7 +11,7 @@ namespace Content.Server.Paper
public string Content { get; set; } = "";
[DataField("contentSize")]
public int ContentSize { get; set; } = 1000;
public int ContentSize { get; set; } = 6000;
[DataField("stampedBy")]
public List<string> StampedBy { get; set; } = new();

View File

@@ -92,7 +92,7 @@ namespace Content.Server.Paper
private void OnInteractUsing(EntityUid uid, PaperComponent paperComp, InteractUsingEvent args)
{
if (_tagSystem.HasTag(args.Used, "Write"))
if (_tagSystem.HasTag(args.Used, "Write") && paperComp.StampedBy.Count == 0)
{
var writeEvent = new PaperWriteEvent(uid, args.User);
RaiseLocalEvent(args.Used, ref writeEvent);
@@ -113,6 +113,8 @@ namespace Content.Server.Paper
_popupSystem.PopupEntity(stampPaperOtherMessage, args.User, Filter.PvsExcept(args.User, entityManager: EntityManager), true);
var stampPaperSelfMessage = Loc.GetString("paper-component-action-stamp-paper-self", ("target", Identity.Entity(args.Target, EntityManager)),("stamp", args.Used));
_popupSystem.PopupEntity(stampPaperSelfMessage, args.User, args.User);
UpdateUserInterface(uid, paperComp);
}
}
@@ -124,7 +126,7 @@ namespace Content.Server.Paper
var text = FormattedMessage.EscapeText(args.Text);
if (text.Length + paperComp.Content.Length <= paperComp.ContentSize)
paperComp.Content += text + '\n';
paperComp.Content = text;
if (TryComp<AppearanceComponent>(uid, out var appearance))
_appearance.SetData(uid, PaperVisuals.Status, PaperStatus.Written, appearance);
@@ -136,6 +138,7 @@ namespace Content.Server.Paper
_adminLogger.Add(LogType.Chat, LogImpact.Low,
$"{ToPrettyString(args.Session.AttachedEntity.Value):player} has written on {ToPrettyString(uid):entity} the following text: {args.Text}");
paperComp.Mode = PaperAction.Read;
UpdateUserInterface(uid, paperComp);
}

View File

@@ -11,7 +11,7 @@
- state: book0
map: [ "enum.DamageStateVisualLayers.Base" ]
- type: Paper
contentSize: 3000
contentSize: 12000
- type: ActivatableUI
key: enum.PaperUiKey.Key
closeOnHandDeselect: false