using System.Numerics; using Robust.Client.Graphics; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; using Robust.Shared.Serialization.TypeSerializers.Implementations.Generic; namespace Content.Client.TextScreen; /// /// A component for rendering text on a screen. /// Can show scrolling text, timers, or other specific-use information (e.g. arrivals timer) /// [RegisterComponent] public sealed partial class TextScreenVisualsComponent : Component { /// /// 1/32 - the size of a pixel in meters. /// public const float PixelSize = 1f / EyeManager.PixelsPerMeter; /// /// The color of the text drawn. /// /// /// 15,151,251 is the old ss13 color, from tg /// [DataField] public Color Color = new Color(15, 151, 251); /// /// Offset for centering the text. /// [DataField] public Vector2 TextOffset = Vector2.Zero; /// /// Offset for centering the timer. /// [DataField] public Vector2 TimerOffset = Vector2.Zero; /// /// Number of rows of text this screen can render. /// [DataField] public int Rows = 2; /// /// Vertical distance between the top pixel of each row. /// [DataField] public int RowOffset = 7; /// /// The amount of characters this component can show per row. /// /// /// Note that scrolling text can show one more than this. /// [DataField] public int RowLength = 5; /// /// Text the screen should show when it finishes a timer. /// [DataField] public string?[] Text = new string?[2]; /// /// Text the screen will draw whenever appearance is updated. /// public string?[] TextToDraw = new string?[2]; /// /// Per-character layers, for mapping into the sprite component. /// [DataField] public Dictionary LayerStatesToDraw = new(); /// /// If true, the screen is able to scroll its text. /// Not used for timers. /// [DataField] public bool ScrollEnabled; /// /// The next time that the text on each row should be scrolled. /// [DataField(customTypeSerializer: typeof(CustomArraySerializer))] public TimeSpan[] NextScrollTime = [TimeSpan.MaxValue, TimeSpan.MaxValue]; /// /// The amount of time between scrolling individual pixels per row. /// [DataField] public TimeSpan[] TimeBetweenScrolls = [TimeSpan.MaxValue, TimeSpan.MaxValue]; /// /// A counter the scroll position of each row. /// Should be used modulo the pixel width of the actual strings. /// [DataField] public int[] ScrollPosition = new int[2]; /// /// The last received text for this screen. Prevents resetting the scroll state on updates. /// [DataField] public string? LastText; /// /// The layer for the outer frame of the text screen. /// Will be registered on top of the other layers. /// [DataField] public PrototypeLayerData? FrameState; /// /// The format string to use for displaying hours when used as a timer. /// [DataField] public string HourFormat = "D2"; /// /// The format string to use for displaying minutes when used as a timer. /// [DataField] public string MinuteFormat = "D2"; /// /// The format string to use for displaying seconds when used as a timer. /// [DataField] public string SecondFormat = "D2"; }