Added a basic vehicle status UI showing mode and a few key datapoints.
This commit is contained in:
1 parent
f05a6148fb
commit
ea6ba54666
15 files changed
+623
No files matched your search
@@ -0,0 +1,29 @@
|
||||
@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()
|
||||
Reference in new issue
Block a user