challenge-editor/scene/select.gd
2024-09-10 14:55:19 +08:00

31 lines
1.5 KiB
GDScript

extends Control
@onready var selected_button:Button=$VBoxContainer/Button1
@onready var btn_group:Array[Button]=[$VBoxContainer/Button1, $VBoxContainer/Button2, $VBoxContainer/Button3, $VBoxContainer/Button4, $VBoxContainer/Button5, $VBoxContainer/Button6]
const SELECTED = preload("res://res/ui/select/selected.tres")
const UNSELECTED = preload("res://res/ui/select/unselected.tres")
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func side_btn_clicked(ind:int):
selected_button.add_theme_stylebox_override("normal",UNSELECTED)
selected_button.add_theme_stylebox_override("pressed",UNSELECTED)
selected_button.add_theme_stylebox_override("hover",UNSELECTED)
selected_button.add_theme_stylebox_override("hover_pressed",UNSELECTED)
var tween = get_tree().create_tween()
tween.tween_property(selected_button, "custom_minimum_size:x", 320, 0.1)
selected_button.z_index-=1
btn_group[ind].add_theme_stylebox_override("normal",SELECTED)
btn_group[ind].add_theme_stylebox_override("pressed",SELECTED)
btn_group[ind].add_theme_stylebox_override("hover",SELECTED)
btn_group[ind].add_theme_stylebox_override("hover_pressed",SELECTED)
btn_group[ind].z_index+=1
var tween2= get_tree().create_tween()
tween2.tween_property(btn_group[ind], "custom_minimum_size:x", 385, 0.1)
selected_button=btn_group[ind]
pass