CatStation/Content.Server/DeviceLinking/Components/SignalTimerComponent.cs
Whatstone 06ebdd462b
Cleanup: Rewrite TextScreenSystem. Timers now wrap the text screen. (#45784)
* 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>
2026-10-02 22:36:32 +00:00

69 lines
1.9 KiB
C#

using Content.Shared.DeviceLinking;
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
namespace Content.Server.DeviceLinking.Components;
/// <summary>
/// A component for signalable timers.
/// Uses a UI to set a label and timer value, and can be started with a signal.
/// Outputs its own signals when the timer starts/finishes.
/// </summary>
[RegisterComponent]
public sealed partial class SignalTimerComponent : Component
{
/// <summary>
/// The current timer delay, used to populate the UI.
/// </summary>
[DataField]
public double Delay = 5;
/// <summary>
/// This shows the Label: text box in the UI.
/// </summary>
[DataField]
public bool CanEditLabel = true;
/// <summary>
/// The label, used for TextScreen visuals currently.
/// </summary>
[DataField]
public string Label = string.Empty;
/// <summary>
/// Default max width of a label (how many letters can this render?)
/// </summary>
[DataField]
public int MaxLength = 16;
/// <summary>
/// The port that gets signaled when the timer triggers.
/// </summary>
[DataField]
public ProtoId<SourcePortPrototype> TriggerPort = "Timer";
/// <summary>
/// The port that gets signaled when the timer starts.
/// </summary>
[DataField]
public ProtoId<SourcePortPrototype> StartPort = "Start";
/// <summary>
/// A port that can be signaled to start the timer.
/// </summary>
[DataField]
public ProtoId<SinkPortPrototype> Trigger = "Trigger";
/// <summary>
/// If not null, this timer will play this sound when done.
/// </summary>
[DataField]
public SoundSpecifier? DoneSound;
/// <summary>
/// The maximum duration in seconds
/// When a larger number is in the input box, the display will start counting down from this one instead
/// </summary>
[DataField]
public double MaxDuration = 3599; // 59m 59s
}