extends Control

func load_main_menu():
	get_tree().change_scene("res://scenes/MainMenu.tscn")


func pause():
	get_tree().paused = true
	show()


func unpause():
	get_tree().paused = false
	hide()


func _ready():
	connect("gui_input", self, '_on_gui_input')

func _input(event: InputEvent):
	if event.is_action_pressed("ui_cancel") and visible:
		unpause()
		get_tree().set_input_as_handled()
	elif event.is_action_pressed("ui_cancel") and not visible:
		pause()
		get_tree().set_input_as_handled()


func _on_BackgroundButton_pressed():
	unpause()


func _on_ContinueButton_pressed():
	unpause()


func _on_MenuButton_pressed():
	unpause()
	load_main_menu()
