small racing game im working on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
extends Button
class_name MultiButton

@export var secondary: Control

func update(_var = null): # cant unbind when connecting signals in code
	var color: StringName = &"font_color"
	if disabled:
		color = &"font_disabled_color"
	elif button_pressed:
		color = &"font_pressed_color"
	elif (is_hovered() if _var == null else _var) || has_focus():
		color = &"font_hover_color"
	set_c(get_theme_color(color))

func set_c(c: Color) -> void:
	if secondary is Label:
		secondary.label_settings.font_color = c
	elif secondary is TextureRect:
		secondary.modulate = c

func _ready() -> void:
	update()
	toggled.connect(update)
	focus_entered.connect(update)
	focus_exited.connect(update)
	mouse_entered.connect(update.bind(true))
	mouse_exited.connect(update.bind(false))
	pressed.connect(update)
	button_up.connect(update)
	button_down.connect(update)