checheche/Robo-Bus-A31-HMI/Modules/language_tabs.gd
2024-12-14 20:09:43 +08:00

41 lines
1.1 KiB
GDScript

extends MarginContainer
#移动背景
@onready var texture_rect: TextureRect = $Control/TextureRect
#需要连接信号的节点数组
@export var nodearr : Array[Node]
signal Onclick(State:int)
var SelectNode = null:
set(value):
if value != SelectNode:
var tween = create_tween()
tween.parallel().tween_property(texture_rect, "global_position", value.global_position, 0.2).set_ease(Tween.EASE_OUT)
tween.parallel().tween_property(texture_rect,"size",value.size,0.2).set_ease(Tween.EASE_OUT)
SelectNode = value
var OnClickIsCooling = false:
set(value):
OnClickIsCooling = value
await get_tree().create_timer(0.2).timeout
OnClickIsCooling = false
func _ready() -> void:
await get_tree().create_timer(0.1).timeout
SelectNode = %Chinese
for node : BaseControl in nodearr:
node.on_click.connect(func(_node):
if !OnClickIsCooling:
SelectNode = _node
OnClickIsCooling = true
Onclick.emit(_node.index)
)
pass # Replace with function body.
#无信号发出模式下设置选择项
func set_select_index_without_signal(index:int):
if index<nodearr.size():
SelectNode=nodearr[index]