extends Control

@onready var settings_menu : Control = $SettingsMenu
@onready var goto_scene : String = "res://scenes/user_interface/title_screen.tscn"

var paused : bool = false

func _ready():
	hide()
	settings_menu.hide()

func _input(event):
	if event.is_action_pressed("ui_cancel") and get_tree().paused and settings_menu.visible == false:
		resume()
	elif event.is_action_pressed("ui_cancel") and !get_tree().paused:
		pause()

func pause():
	Input.mouse_mode = Input.MOUSE_MODE_VISIBLE
	get_tree().paused = true
	show()

func resume():
	Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
	get_tree().paused = false
	hide()
	settings_menu.hide()


func _on_resume_pressed():
	resume()


func _on_settings_button_pressed():
	settings_menu.show()


func _on_quit_button_pressed():
	get_tree().paused = false
	SceneSwitcher.transition_scene(goto_scene)
