LargeScreen/Modules/language_button.gd
2024-12-17 18:21:12 +08:00

60 lines
1.2 KiB
GDScript

extends Button
@export var BackTextureNormal:Texture2D
@export var BackTextureSelected:Texture2D
@export var IconTextureNormal:Texture2D
@export var IconTextureSelected:Texture2D
@export var TextColorNormal:Color
@export var TextColorSelected:Color
@export var Text:String
signal click(node)
var is_selected:bool=false:
set(value):
if value!=is_selected:
if value:
%back.texture=BackTextureSelected
%icon.texture=IconTextureSelected
%text.add_theme_color_override("font_color",TextColorSelected)
bold_label(%text)
else:
%back.texture=BackTextureNormal
%icon.texture=IconTextureNormal
%text.add_theme_color_override("font_color",TextColorNormal)
unbold_label(%text)
is_selected=value
func _ready() -> void:
%back.texture=BackTextureNormal
%icon.texture=IconTextureNormal
%text.add_theme_color_override("font_color",TextColorNormal)
%text.text=Text
pass
func _pressed() -> void:
click.emit(self)
is_selected=not is_selected
func bold_label(label:Label):
label.add_theme_color_override("font_outline_color",label.get_theme_color("font_color"))
label.add_theme_constant_override("outline_size",5)
func unbold_label(label:Label):
label.add_theme_constant_override("outline_size",0)