online multiplayer chess game (note server currently down)
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
32
33
|
extends GridContainer
class_name GridMenu
const texture_button = preload("res://ui/barbutton/BarTextureButton.tscn")
signal pressed(index)
func open():
columns = round(sqrt(get_child_count()))
show()
func add_item(icon: Texture, tooltip: String, size: Vector2) -> void:
var tex := texture_button.instance()
tex.connect("pressed", self, "_pressed", [get_child_count()])
tex.expand = true
tex.texture_normal = icon
tex.name = tooltip
tex.rect_min_size = size
tex.hint_tooltip = tooltip
tex.stretch_mode = tex.STRETCH_KEEP_ASPECT_CENTERED
tex.set_anchors_preset(PRESET_WIDE)
var back: ColorRect = tex.get_node("Background")
back.margin_left = -5
back.margin_right = 5
back.margin_top = -5
back.margin_bottom = 5
add_child(tex)
func _pressed(index: int):
get_children()[index].get_children()[0]._focused(false)
emit_signal("pressed", index)
|