online multiplayer chess game (note server currently down)
Diffstat (limited to 'ui/BarTextureButton.gd')
| -rw-r--r-- | ui/BarTextureButton.gd | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/ui/BarTextureButton.gd b/ui/BarTextureButton.gd new file mode 100644 index 0000000..cd3776a --- /dev/null +++ b/ui/BarTextureButton.gd @@ -0,0 +1,42 @@ +extends Control +class_name BarTextureButton + +signal pressed() + +var focused = false + +export(Texture) var texture + +export(Color) var normal_color +export(Color) var highlight_color +export(Color) var pressed_color + +onready var texture_button = $Texture +onready var background = $Background + +func _ready(): + texture_button.texture_normal = texture + texture_button.texture_focused = texture + texture_button.texture_pressed = texture + texture_button.texture_hover = texture + +func _on_Texture_pressed(): + emit_signal("pressed") + +func _process(_delta): + if texture_button.pressed: + background.color = pressed_color + elif focused: + background.color = highlight_color + else: + background.color = normal_color + +func _on_Texture_mouse_entered(): + focused = true + background.color = highlight_color + + +func _on_Texture_mouse_exited(): + focused = false + background.color = normal_color + |