extends Control


var is_paused = false

func _ready():

	set_process(true)

func update_pause_status():
		get_tree().paused = is_paused
		visible = is_paused
		if is_paused == true:
			Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
		else:
			Input.set_mouse_mode(Input.MOUSE_MODE_HIDDEN)
			
func _process(delta):
	
	#print ("running")
	if Input.is_action_just_pressed("ui_cancel"):
		#print ("pause!")
		is_paused = !is_paused
		
		update_pause_status()
		


func _on_ResumeGameButton_pressed():
	is_paused = false
	update_pause_status()



func _on_RestartGameButton_pressed():
	is_paused = false
	update_pause_status()
		
	get_tree().reload_current_scene()


func _on_ExitGameButton_pressed():
	
	is_paused = false
	update_pause_status()
	get_tree().change_scene("res://UI/LevelSelectionScreen.tscn")	
	Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
	
	#get_node("/root/global").changeToCustomScene("res://MainMenu.tscn")
