class_name OptionsMenu
extends Control

@onready var username_input: LineEdit = $OptionsList/UsernameOption/OptionInput
@onready var ip_address_input: LineEdit = $OptionsList/IpAddressOption/OptionInput
@onready var data_collection_input: CheckBox = $OptionsList/DataCollectionOption/OptionInput

func _ready() -> void:
	username_input.text = Options.username
	ip_address_input.text = Options.ip_address
	data_collection_input.button_pressed = Options.data_collection

func _username_changed(text: String) -> void:
	Options.username = text
	Options.save_options()

func _ip_address_changed(text: String) -> void:
	Options.ip_address = text
	Options.save_options()

func _data_collection_changed(new_option: bool) -> void:
	Options.data_collection = new_option
	Options.save_options()

func _main_menu() -> void:
	if get_tree().change_scene_to_file("res://ui/main_menu.tscn") != OK:
		print("Failed to change to scene.")
