extends Node

onready var setting = load("res://db/MSetting.gd").new()

func _ready():
	apply_language(translate_int_to_locale(get_setting_language()))
	apply_resolution()
	apply_fullscreen()

func apply_language(local):
	TranslationServer.set_locale(local)

func translate_int_to_locale(id):
	var lang = "en_GB"

	if id == 0:
		lang = "en_GB"

	if id == 1:
		lang = "fr_FR"

	return lang

func apply_resolution():
	var screen_size = Vector2(get_setting_resolution()[0], get_setting_resolution()[1])
	var margin_size = Vector2(0, 0)
	get_viewport().set_size_override(true, screen_size, margin_size)

func apply_fullscreen():
	OS.set_window_fullscreen(get_setting_fullscreen())

func get_setting_language():
	return setting.get_langue()

func set_setting_language(value):
	setting.set_langue(value)
	apply_language(translate_int_to_locale(value))

func get_setting_gyrosocpe():
	return setting.get_gyroscope()

func set_setting_gyroscope(value):
	setting.set_gyroscope(value)

func get_setting_ambient_sound():
	return setting.get_ambient_sound()

func set_setting_ambient_sound(value):
	setting.set_ambient_sound(value)

func get_setting_resolution():
	return setting.get_resolution()

func set_setting_resolution(value):
	setting.set_resolution(value)
	apply_resolution()

func get_setting_fullscreen():
	return setting.get_fullscreen()

func set_setting_fullscreen(value):
	setting.set_fullscreen(value)
	apply_fullscreen()

func get_setting_version():
	return setting.get_version()
