thegates/app/scripts/ui/hint.gd
2025-06-29 01:26:39 +07:00

32 lines
711 B
GDScript

extends Control
@export var section: String = "hints"
@export var key: String = ""
@export var button: BaseButton
func _ready() -> void:
visible = false
if key.is_empty() or button == null: Debug.logerr("hint has empty vars")
var is_shown = DataSaver.get_value(section, key, false)
if not is_shown: show_hint()
func _notification(what: int) -> void:
if not what == NOTIFICATION_VISIBILITY_CHANGED: return
if is_visible_in_tree(): play_anim()
func show_hint() -> void:
visible = true
play_anim()
if button != null: button.pressed.connect(hide_hint)
func play_anim() -> void:
$AnimationPlayer.play("Bounce")
func hide_hint() -> void:
visible = false
DataSaver.set_value(section, key, true)