mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
* Half the way to making the text screen less jank * quarter-assed timer * partial update * fleshing out timing & scrolling in update * common IGameTiming * Back to AppearanceData * partial appearance data system * funny timer states * mostly working timer scroll (damned edge pixels) * screen: scroll offset + hide * SignalTimer: remove time set on text update * extend for timer * TextScreenVisuals: cleanup * restore old names * Return old names, write more comments * fix textscreensystem ref, consistent timer frame * comments, "TextScreenVisualsComponent" * TextScreenTimerVisualsComponent, diff reduction * region * system order * no "client-side" comments * small bugfixes & cleanup with devicenet refactor * consolidate string formatting * Restore ETA/ETD text * No need for DefaultText for regular screen text * Address Pok's suggestions Co-authored-by: Pok27 <113675512+Pok27@users.noreply.github.com> * formatting * pok suggesto round 2, blyatin-1 also clean up the string vs. display value mess * TextScreenSystem.GetString -> TimerDisplay.ToStr * D2 begone! * constants to component values * comment update + SignalTimerWindow whitespace * a touch of numerical safety fixes a few errors from pasting huge text * fields aren't properties :^) * DataDef time * Update TextScreenSystem.cs * Update TextScreenTimerVisualsComponent.cs * return the pause, bunch of comments, missed a comp --------- Co-authored-by: Pok27 <113675512+Pok27@users.noreply.github.com>
94 lines
2.8 KiB
C#
94 lines
2.8 KiB
C#
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
|
|
|
namespace Content.Client.TextScreen;
|
|
|
|
/// <summary>
|
|
/// A component for text screens that support countdown timers with frame-by-frame updates.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Entities must have <see cref="TextScreenVisualsComponent"/> to work!
|
|
/// </remarks>
|
|
[RegisterComponent, Access(typeof(TextScreenSystem))]
|
|
[AutoGenerateComponentPause]
|
|
public sealed partial class TextScreenTimerVisualsComponent : Component
|
|
{
|
|
/// <summary>
|
|
/// The time that the timer is counting down to.
|
|
/// </summary>
|
|
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
|
|
[AutoPausedField]
|
|
public TimeSpan? TargetTime;
|
|
|
|
/// <summary>
|
|
/// The text to render onto the screen while the timer is running.
|
|
/// </summary>
|
|
[DataField]
|
|
public string RunningText = "";
|
|
|
|
/// <summary>
|
|
/// The string to draw onto the screen when the target time is reached.
|
|
/// </summary>
|
|
[DataField]
|
|
public string FinishedText = "";
|
|
|
|
/// <summary>
|
|
/// The 0-indexed row to use for the timer data.
|
|
/// </summary>
|
|
[DataField]
|
|
public int TimerRow;
|
|
|
|
/// <summary>
|
|
/// If true, the timer will show small durations with centisecond precision.
|
|
/// If false, times will be shown with second precision at most.
|
|
/// </summary>
|
|
[DataField]
|
|
public bool ShowCentiseconds = true;
|
|
|
|
/// <summary>
|
|
/// The last value being displayed on the screen.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// A value of all zeros implies the timer is done, and <see cref="FinishedText"/> should be displayed instead.
|
|
[DataField]
|
|
public TimerDisplay ScreenValue;
|
|
|
|
/// <summary>
|
|
/// The state to use for the <see cref="TimerVisualLayers.Light"/> layer when the timer is in progress.
|
|
/// </summary>
|
|
[DataField]
|
|
public string? RunningState;
|
|
|
|
/// <summary>
|
|
/// The state to use for the <see cref="TimerVisualLayers.Light"/> layer when the timer elapses.
|
|
/// </summary>
|
|
[DataField]
|
|
public string? FinishedState;
|
|
}
|
|
|
|
/// <summary>
|
|
/// A value to display on a timer, agnostic of time unit.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// Values to be expressed as <c>HIGH:LOW</c>, both values effectively capped at 99.
|
|
/// Used to avoid string comparisons.
|
|
/// </remarks>
|
|
[DataDefinition, Serializable]
|
|
public partial record struct TimerDisplay(int HighValue, int LowValue)
|
|
{
|
|
public override readonly string ToString()
|
|
{
|
|
var high = int.Clamp(HighValue, 0, 99);
|
|
var low = int.Clamp(LowValue, 0, 99);
|
|
return $"{high:D2}:{low:D2}";
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sprite layers for text screen timers.
|
|
/// </summary>
|
|
[Serializable]
|
|
public enum TimerVisualLayers : byte
|
|
{
|
|
/// <summary>A light that turns on with the status of the timer.</summary>
|
|
Light
|
|
}
|