extends TextureButton

func _ready():
	grab_focus()

func _on_TextureButton_pressed():
	$"../GameSelector".popup()
	$"../GameSelector/TabContainer/Minigames/Golf Cart Time Trial".grab_focus()
	Input.start_joy_vibration(0, 1, 1, 0.1)
	Input.vibrate_handheld(100)
	var player = AudioStreamPlayer.new()
	self.add_child(player)
	player.stream = load("res://assets/sounds/click.wav")
	player.play()


func _on_ButtonIconSettings_pressed():
	$"../SettingsDialog".popup()

	Input.start_joy_vibration(0, 1, 1, 0.1)
	Input.vibrate_handheld(100)
	var player = AudioStreamPlayer.new()
	self.add_child(player)
	player.stream = load("res://assets/sounds/click.wav")
	player.play()


func _on_ButtonIconWebsite_pressed():
	Input.start_joy_vibration(0, 1, 1, 0.1)
	Input.vibrate_handheld(100)
	var player = AudioStreamPlayer.new()
	self.add_child(player)
	player.stream = load("res://assets/sounds/click.wav")
	player.play()
	OS.shell_open("https://hnr.clygro.cc") 


func _on_ButtonIconCredits_pressed():
	$"../AboutDialog".popup()
#	$"../AboutDialog/TabContainer/About/ChangelogButton".grab_focus()
	Input.start_joy_vibration(0, 1, 1, 0.1)
	Input.vibrate_handheld(100)
	var player = AudioStreamPlayer.new()
	self.add_child(player)
	player.stream = load("res://assets/sounds/click.wav")
	player.play()


func _on_ButtonIconClose_pressed():
	$"../ConfirmationDialog".popup()
	Input.start_joy_vibration(0, 1, 1, 0.1)
	Input.vibrate_handheld(100)
	var player = AudioStreamPlayer.new()
	self.add_child(player)
	player.stream = load("res://assets/sounds/click.wav")
	player.play()
	
func _input(event):
	if Input.is_action_pressed("ui_cancel"):
		$"../ConfirmationDialog".popup()
		Input.start_joy_vibration(0, 1, 1, 0.1)
		Input.vibrate_handheld(100)
