if (args.AppearanceData.TryGetValue(TextScreenVisuals.Color, out var color) && color is Color)
component.Color = (Color) color;
- // DefaultText: broadcast updates from comms consoles
- // ScreenText: the text accompanying shuttle timers e.g. "ETA"
+ // DefaultText: fallback text e.g. broadcast updates from comms consoles
if (args.AppearanceData.TryGetValue(TextScreenVisuals.DefaultText, out var newDefault) && newDefault is string)
- {
- string?[] defaultText = SegmentText((string) newDefault, component);
- component.Text = defaultText;
- component.TextToDraw = defaultText;
- ResetText(uid, component);
- BuildTextLayers(uid, component, args.Sprite);
- DrawLayers(uid, component.LayerStatesToDraw);
- }
+ component.Text = SegmentText((string) newDefault, component);
+
+ // ScreenText: currently rendered text e.g. the "ETA" accompanying shuttle timers
if (args.AppearanceData.TryGetValue(TextScreenVisuals.ScreenText, out var text) && text is string)
{
component.TextToDraw = SegmentText((string) text, component);
private void OnInit(EntityUid uid, SignalTimerComponent component, ComponentInit args)
{
+ _appearanceSystem.SetData(uid, TextScreenVisuals.DefaultText, component.Label);
_appearanceSystem.SetData(uid, TextScreenVisuals.ScreenText, component.Label);
_signalSystem.EnsureSinkPorts(uid, component.Trigger);
}
{
RemComp<ActiveSignalTimerComponent>(uid);
- if (TryComp<AppearanceComponent>(uid, out var appearance))
- {
- _appearanceSystem.SetData(uid, TextScreenVisuals.ScreenText, signalTimer.Label, appearance);
- }
-
_audio.PlayPvs(signalTimer.DoneSound, uid);
_signalSystem.InvokePort(uid, signalTimer.TriggerPort);
if (!IsMessageValid(uid, args))
return;
- component.Label = args.Text[..Math.Min(5, args.Text.Length)];
+ component.Label = args.Text[..Math.Min(component.MaxLength, args.Text.Length)];
if (!HasComp<ActiveSignalTimerComponent>(uid))
+ {
+ // could maybe move the defaulttext update out of this block,
+ // if you delved deep into appearance update batching
+ _appearanceSystem.SetData(uid, TextScreenVisuals.DefaultText, component.Label);
_appearanceSystem.SetData(uid, TextScreenVisuals.ScreenText, component.Label);
+ }
}
/// <summary>
{
if (!IsMessageValid(uid, args))
return;
- OnStartTimer(uid, component);
+
+ // feedback received: pressing the timer button while a timer is running should cancel the timer.
+ if (HasComp<ActiveSignalTimerComponent>(uid))
+ {
+ _appearanceSystem.SetData(uid, TextScreenVisuals.TargetTime, _gameTiming.CurTime);
+ Trigger(uid, component);
+ }
+ else
+ OnStartTimer(uid, component);
}
private void OnSignalReceived(EntityUid uid, SignalTimerComponent component, ref SignalReceivedEvent args)