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
34
35
36
37
38
39
40
41
extends Control
class_name Confirm

signal confirmed(what)

export(NodePath) onready var status = get_node(status) as StatusLabel

var timer := Timer.new()
var looking: Node = null


func _ready() -> void:
	add_child(timer)
	timer.connect("timeout", self, "_pressed", [false])


func _timeout() -> void:
	_pressed(false)


func stop_looking() -> void:
	looking = null
	timer.stop()
	hide()


func confirm(who: Node, what: String, timeout := 5):
	if is_instance_valid(looking):
		looking.stoplooking()
	looking = who
	show()
	status.set_text(what, timeout)
	timer.start(timeout)


func _pressed(what: bool):
	for i in $H.get_children():
		i._focused(false)
	status.set_text("", 0)
	emit_signal("confirmed", what)
	stop_looking()