online multiplayer chess game (note server currently down)
Diffstat (limited to 'ui/gridmenu/GridMenu.gd')
| -rw-r--r-- | ui/gridmenu/GridMenu.gd | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/ui/gridmenu/GridMenu.gd b/ui/gridmenu/GridMenu.gd index 0dda398..6d14477 100644 --- a/ui/gridmenu/GridMenu.gd +++ b/ui/gridmenu/GridMenu.gd @@ -4,22 +4,24 @@ 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: + +func add_item(icon: Texture, tooltip: String, size: Vector2) -> void: var pnl := PanelContainer.new() var tex := texture_button.instance() tex.connect("pressed", self, "_pressed", [get_child_count()]) tex.expand = true tex.texture_normal = icon - tex.name = str(get_child_count()+1) + tex.name = str(get_child_count() + 1) 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") + var back: ColorRect = tex.get_node("Background") back.margin_left = -5 back.margin_right = 5 back.margin_top = -5 @@ -27,6 +29,7 @@ func add_item(icon : Texture, tooltip : String, size:Vector2)->void: pnl.add_child(tex) add_child(pnl) -func _pressed(index:int): + +func _pressed(index: int): get_children()[index].get_children()[0]._focused(false) emit_signal("pressed", index) |