xiandie/scene/entity/ux/content_inspector.gd

49 lines
1.1 KiB
GDScript3
Raw Normal View History

2025-06-25 17:53:16 +00:00
extends Control
class_name ContentInspector
signal display_toggled(displaying: bool)
2025-06-25 17:53:16 +00:00
@onready var label = $TipContainer/Label as Label
var tip_can_show = "Q: " + tr("ui_退出") + " " + "E: " + tr("ui_阅读")
var tip_can_hide = "Q: " + tr("ui_退出") + " " + "E: " + tr("ui_收起")
var displaying := false
2025-06-25 17:53:16 +00:00
var blinking_tween: Tween
func _ready() -> void:
# tween tips
blinking_tween = create_tween()
blinking_tween.tween_property(label, "modulate:a", 0.8, 2.0)
blinking_tween.tween_property(label, "modulate:a", 1.0, 2.0)
blinking_tween.set_loops(-1)
setup_display()
2025-06-25 17:53:16 +00:00
func setup_display(display := displaying):
displaying = display
2025-06-25 17:53:16 +00:00
for c in get_children():
if c.name == "TipContainer":
continue
c.set("visible", displaying)
2025-06-25 17:53:16 +00:00
# reset_tips
if displaying:
label.text = tip_can_hide
else:
label.text = tip_can_show
func _unhandled_input(event: InputEvent) -> void:
2025-07-22 11:59:08 +00:00
if not is_visible_in_tree():
return
2025-06-25 17:53:16 +00:00
if event.is_action_pressed("interact"):
2025-07-14 15:16:32 +00:00
get_viewport().set_input_as_handled()
displaying = not displaying
if displaying:
$"Sfx显示".play()
2025-06-25 17:53:16 +00:00
else:
$"Sfx收起".play()
setup_display()
display_toggled.emit(displaying)