-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathPopupMenu.gd
56 lines (43 loc) · 1.19 KB
/
PopupMenu.gd
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
50
51
52
53
54
55
56
extends Control
signal restartGame
sync func rpcSetPause(val, playername):
get_tree().get_nodes_in_group("currentPlayer")[0].resetKeys()
print(val, " ", playername)
var pauseGameScreen = get_tree().get_root().get_node("Control/PauseGameScreen")
# if not is_network_master():
if val:
print("would show")
pauseGameScreen.setPlayerPaused(playername)
else:
pauseGameScreen.hide()
get_tree().set_pause(val)
func setPause(val):
var playername = get_tree().get_nodes_in_group("currentPlayer")[0].playerName
rpc("rpcSetPause",val, playername)
func showMenu():
setPause(true)
self.visible = true
func hideMenu():
self.visible = false
setPause(false)
func _ready():
set_process_input(true)
func _on_ButtonResume_pressed():
hideMenu()
func _on_ButtonRestart_pressed():
setPause(false)
emit_signal("restartGame")
func _on_ButtonMenu_pressed():
setPause(false)
get_tree().change_scene("res://lobby.tscn")
func _on_ButtonQuit_pressed():
setPause(false)
get_tree().quit()
func _on_Settings_pressed():
get_tree().get_root().get_node("Control/menu/Settings").show()
func _input(event):
if event.is_action_pressed("ui_cancel"):
if self.visible:
self.hideMenu()
else:
self.showMenu()