Files
SurfaceSide-UI/scripts/vehicle_status_art.gd

30 lines
795 B
GDScript

@tool
extends Control
@export_enum("Normal", "Warning", "Fault", "No data") var severity := 3
@export var pulse_alerts := true
var _phase := -1
func _ready() -> void:
resized.connect(queue_redraw)
theme_changed.connect(_update_icon)
_update_icon()
func _process(_delta: float) -> void:
var phase := int(Time.get_ticks_msec() / 1000.0) % 2 if pulse_alerts else 0
if phase != _phase:
_phase = phase
queue_redraw()
func _draw() -> void:
if severity in [1, 2]:
var role := "warning" if severity == 1 else "fault"
if _phase == 1:
role += "_alternate"
draw_rect(Rect2(Vector2.ZERO, size), get_theme_color(role, "SurfaceSide"))
func _update_icon() -> void:
var tint := get_theme_color("status_icon", "SurfaceSide")
tint.a = 0.09
$ModeIcon.self_modulate = tint
queue_redraw()