online multiplayer chess game (note server currently down)
Diffstat (limited to 'ui/barbutton/BarTextureButton.gd')
-rw-r--r--ui/barbutton/BarTextureButton.gd44
1 files changed, 44 insertions, 0 deletions
diff --git a/ui/barbutton/BarTextureButton.gd b/ui/barbutton/BarTextureButton.gd
new file mode 100644
index 0000000..548ac0c
--- /dev/null
+++ b/ui/barbutton/BarTextureButton.gd
@@ -0,0 +1,44 @@
+extends TextureButton
+class_name BarTextureButton
+
+var focused: bool setget _focused
+
+export(Color) var normal_color: Color
+export(Color) var highlight_color: Color
+export(Color) var pressed_color: Color
+export(Color) var disabled_color: Color
+
+onready var background := $Background
+
+var n := 0
+
+
+func _ready() -> void:
+ _focused(false)
+ n = round(rand_range(10, 20))
+
+
+func set_disabled(new: bool) -> void:
+ disabled = new
+ self_modulate = Color.gray if disabled else Color.white
+ mouse_default_cursor_shape = CURSOR_FORBIDDEN if disabled else CURSOR_POINTING_HAND
+
+
+func _process(_delta):
+ if visible:
+ _update()
+
+
+func _update():
+ if disabled:
+ background.color = disabled_color
+ elif pressed:
+ background.color = pressed_color
+ elif focused:
+ background.color = highlight_color
+ else:
+ background.color = normal_color
+
+
+func _focused(q: bool):
+ focused = q