2025-06-25 17:53:16 +00:00
|
|
|
extends Control
|
|
|
|
class_name ContentInspector
|
|
|
|
|
2025-07-24 15:44:36 +00:00
|
|
|
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_收起")
|
|
|
|
|
2025-07-24 15:44:36 +00:00
|
|
|
var displaying := false
|
2025-06-25 17:53:16 +00:00
|
|
|
|
|
|
|
var blinking_tween: Tween
|
|
|
|
|
|
|
|
|
|
|
|
func _ready() -> void:
|
2025-07-24 15:44:36 +00:00
|
|
|
# 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
|
|
|
|
|
|
|
|
2025-07-24 15:44:36 +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
|
2025-07-05 18:13:12 +00:00
|
|
|
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():
|
2025-06-26 10:19:59 +00:00
|
|
|
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()
|
2025-07-24 15:44:36 +00:00
|
|
|
displaying = not displaying
|
|
|
|
if displaying:
|
2025-07-05 18:13:12 +00:00
|
|
|
$"Sfx显示".play()
|
2025-06-25 17:53:16 +00:00
|
|
|
else:
|
2025-07-05 18:13:12 +00:00
|
|
|
$"Sfx收起".play()
|
2025-07-24 15:44:36 +00:00
|
|
|
setup_display()
|
|
|
|
display_toggled.emit(displaying)
|