summaryrefslogtreecommitdiff
path: root/stage/hud_main.gd
blob: b80b514746e469d768ca2c373597eb1dffd8de02 (plain)
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
42
43
44
45
46
47
48
49
extends CanvasLayer


@onready var grid_selector: GridSelector = get_tree().get_first_node_in_group("grid_selector")


func _ready() -> void:
	visible = false


func _input(event: InputEvent) -> void:
	if not visible:
		return
	
	if event.is_action_pressed("left_click"):
		for button: Button in $PanelContainer/VBoxContainer.get_children():
			if button.has_focus():
				button.pressed.emit()
				break
	
	if event.is_action_pressed("menu") or event.is_action_pressed("right_click"):
		visible = false
		grid_selector.process_mode = Node.PROCESS_MODE_INHERIT


func _on_button_pressed() -> void:
	visible = false
	
	var dice_throw_scene = load("res://stage/dice_throw/dice_throw.tscn")
	var dice_throw = dice_throw_scene.instantiate()
	get_tree().root.add_child(dice_throw)
	dice_throw.position -= dice_throw.size * 0.5
	dice_throw.throw_finished.connect(func():
		dice_throw.queue_free()
		get_tree().current_scene.process_mode = PROCESS_MODE_INHERIT
		grid_selector.process_mode = PROCESS_MODE_INHERIT
		grid_selector.current_state = grid_selector.state_cube_placement
	)
	get_tree().current_scene.process_mode = PROCESS_MODE_DISABLED


func _on_button_2_pressed() -> void:
	visible = false
	
	Network.set_current_player(Network.player_order[
		(Network.player_order.find(Network.current_player.id) + 1) % Network.player_order.size()
	])
	
	grid_selector.process_mode = Node.PROCESS_MODE_INHERIT