Files
darknight 0debe0d2d3 feature/update-main-ui (#66)
Co-authored-by: stilobique-i7 <aurelienvlt@free.fr>
Co-authored-by: VAILLANT Jeremy <vaillant.jeremy@dev-crea.com>
Reviewed-on: Athena/game-source#66
Co-authored-by: darknight <vaillant.jeremy@dev-crea.com>
Co-committed-by: darknight <vaillant.jeremy@dev-crea.com>
2021-06-03 22:18:50 +02:00

59 lines
2.1 KiB
GDScript

extends Node
func _ready():
_apply_translation()
_apply_settings_language()
_apply_settings_gyroscope()
_apply_settings_sound_ambient()
_apply_settings_resolution()
_apply_settings_fullscreen()
## PRIVATE
func _apply_translation():
$VBoxContainer/langue/VBoxContainer/Label.text = tr("SETTINGS_LABEL_LANGUE")
$VBoxContainer/gyroscope/HBoxContainer/Label.text = tr("SETTINGS_LABEL_GYROSCOPE")
func _apply_settings_language():
var data = $VBoxContainer/langue/VBoxContainer/data
data.add_item("English", load("res://assets/ui/flags/english.png"), true) # id : 0
data.add_item("Français", load("res://assets/ui/flags/french.png"), true) # id : 1
data.select(Setting.get_setting_language())
func _apply_settings_gyroscope():
$VBoxContainer/gyroscope/HBoxContainer/data.set_pressed(Setting.get_setting_gyrosocpe())
func _apply_settings_sound_ambient():
$VBoxContainer/ambient_sound/HBoxContainer/data.set_pressed(Setting.get_setting_ambient_sound())
func _apply_settings_resolution():
var data = $VBoxContainer/resolution/VBoxContainer/data
data.add_item("2560 x 1440", null, true) # id : 0
data.add_item("1920 x 1080", null, true) # id : 1
data.add_item("1280 x 720", null, true) # id : 2
data.add_item("854 x 576", null, true) # id : 3
for index in range(4):
if data.get_item_text(index).split(' x ') == Setting.get_setting_resolution():
data.select(index)
func _apply_settings_fullscreen():
$VBoxContainer/fullscreen/HBoxContainer/data.set_pressed(Setting.get_setting_fullscreen())
func _on_gyroscope_pressed():
Setting.set_setting_gyroscope(int($VBoxContainer/gyroscope/HBoxContainer/data.pressed))
func _on_ambient_sound_pressed():
Setting.set_setting_ambient_sound(int($VBoxContainer/ambient_sound/HBoxContainer/data.pressed))
func _on_langue_item_selected(index):
Setting.set_setting_language(index)
func _on_resolution_item_selected(index):
Setting.set_setting_resolution($VBoxContainer/resolution/VBoxContainer/data.get_item_text(index))
func _on_fullscreen_item_selected():
Setting.set_setting_fullscreen(int($VBoxContainer/fullscreen/HBoxContainer/data.pressed))