extends Node2D

var exit_release = true

func _ready():
	pause_mode = PAUSE_MODE_PROCESS
	self.visible = false
	$PlayerBarBlur.layer = -1

func _physics_process(_delta):
	if Input.is_action_pressed("ui_exit") and exit_release:
		get_tree().paused = !get_tree().paused 
		self.visible = !self.visible
		if $PlayerBarBlur.layer == -1:
			$PlayerBarBlur.layer = 1
		else:
			$PlayerBarBlur.layer = -1
		if Input.get_mouse_mode() == Input.MOUSE_MODE_CAPTURED:
			Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
		else:
			Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
		exit_release = false

	if !Input.is_action_pressed("ui_exit"):
		exit_release = true

func _on_ContinueButton_pressed():
	self.visible = false
	$PlayerBarBlur.layer = -1
	get_tree().paused = false
	Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)

func _on_MenuButton_pressed():
	Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
	$Transit.change_scene("res://levels/Menu.tscn", 0.5, 0.2)
	get_tree().paused = false

func _on_ExitButton_pressed():
	$ExitDialog.visible = true
