
extends Control

var song = preload("res://audio/music/main_menu.it")

func _ready():
	Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
	audio.play_stream(song)
	get_node("opt_menu/control_type").set_text(global.control_types[global.curent_control_type])
	get_node("opt_menu/resolution").set_text(str(global.screen_resolutions[global.curent_resolution_index]))
	if global.show_missions_list:
		global.show_missions_list = false
		_on_new_button_pressed()

func _on_opt_button_pressed():
	get_node("tittle_menu").hide()
	get_node("opt_menu").show()
	print("press")

func _on_opt_canc_button_pressed():
	get_node("opt_menu").hide()
	get_node("tittle_menu").show()

func _on_quit_button_pressed():
	get_tree().quit()

func _on_music_volume_value_changed( value ):
	audio.change_music_volume(value)

func _on_sounds_volume_value_changed( value ):
	audio.get_node("sounds").set_default_volume(value)

func _on_control_change(changer):
	var new_text = global.change_control_type(changer)
	get_node("opt_menu/control_type").set_text(new_text)
	
func _on_resolution_change(changer):
	var new_text = global.change_resolution(changer)
	if new_text!="":
		get_node("opt_menu/resolution").set_text(new_text)

func _on_new_button_pressed():
	get_node("level_sel_menu").show()
	get_node("tittle_menu").hide()

func _on_lvls_canc_button_pressed():
	get_node("level_sel_menu").hide()
	get_node("tittle_menu").show()	

func _on_level_select(var lvl_id):
	global.load_level_firstly ("res://scenes/levels/level_" + str(lvl_id) + ".scn")

func _on_cred_button_pressed():
	get_node("crdts_menu").show()
	get_node("tittle_menu").hide()

func _on_cred_canc_button_pressed():
	get_node("crdts_menu").hide()
	get_node("tittle_menu").show()
