grunk/src/ui/hud/interact_hud.gd

42 lines
926 B
GDScript3
Raw Normal View History

class_name InteractHUD extends Control
# Pops up when the player is looking at something interactable.
const TRANSITION_TIME := 0.06
const COLOR_VISIBLE := Color("#ffffffee")
const COLOR_DISABLED := Color("#cccccc44")
const COLOR_INVISIBLE := Color("#ffffff00")
@onready var interact_name: Label = %InteractName
@onready var interact_verb: Label = %InteractVerb
func _transition_color(color: Color) -> void:
create_tween().tween_property(self, "modulate", color, TRANSITION_TIME).set_trans(
Tween.TRANS_CUBIC
)
func _to_visible() -> void:
_transition_color(COLOR_VISIBLE)
func _to_disabled() -> void:
_transition_color(COLOR_DISABLED)
func _to_invisible() -> void:
_transition_color(COLOR_INVISIBLE)
func set_prop(prop: Interactive) -> void:
if prop:
interact_name.text = prop.label
interact_verb.text = prop.verb
if prop.enabled:
_to_visible()
else:
_to_disabled()
else:
_to_invisible()