29 lines
929 B
GDScript
29 lines
929 B
GDScript
extends Control
|
|
|
|
# Pre-create flat styles to override the engine's default skin
|
|
var active_style = StyleBoxFlat.new()
|
|
var inactive_style = StyleBoxFlat.new()
|
|
|
|
func _ready():
|
|
# Configure your exact custom colors
|
|
active_style.bg_color = Color(0.378, 0.378, 0.378, 0.988)
|
|
inactive_style.bg_color = Color(0.075, 0.075, 0.075, 0.988)
|
|
|
|
func setItem(item, isActive):
|
|
$TextureRect.texture = item.texture
|
|
|
|
if isActive:
|
|
# Force-override all basic button background states
|
|
$Button.add_theme_stylebox_override("normal", active_style)
|
|
$Button.add_theme_stylebox_override("hover", active_style)
|
|
$Button.add_theme_stylebox_override("pressed", active_style)
|
|
else:
|
|
$Button.add_theme_stylebox_override("normal", inactive_style)
|
|
$Button.add_theme_stylebox_override("hover", inactive_style)
|
|
$Button.add_theme_stylebox_override("pressed", inactive_style)
|
|
|
|
|
|
|
|
func _on_button_pressed() -> void:
|
|
pass # Replace with function body.
|