Files
puzzle-quest/scenes/UI/settings/Settings.gd
T

59 lines
2.1 KiB
GDScript
Raw Normal View History

2021-05-13 20:01:51 +02:00
extends Node
func _ready():
2021-05-29 21:09:10 +02:00
_apply_translation()
_apply_settings_language()
_apply_settings_gyroscope()
2021-05-23 21:33:44 +02:00
_apply_settings_sound_ambient()
2021-05-29 21:09:10 +02:00
_apply_settings_resolution()
_apply_settings_fullscreen()
2021-05-13 20:01:51 +02:00
## PRIVATE
2021-05-29 21:09:10 +02:00
func _apply_translation():
$VBoxContainer/langue/VBoxContainer/Label.text = tr("SETTINGS_LABEL_LANGUE")
$VBoxContainer/gyroscope/HBoxContainer/Label.text = tr("SETTINGS_LABEL_GYROSCOPE")
2021-05-13 20:01:51 +02:00
func _apply_settings_language():
2021-05-29 21:09:10 +02:00
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
2021-06-03 22:18:50 +02:00
data.select(Setting.get_setting_language())
2021-05-13 20:01:51 +02:00
func _apply_settings_gyroscope():
2021-06-03 22:18:50 +02:00
$VBoxContainer/gyroscope/HBoxContainer/data.set_pressed(Setting.get_setting_gyrosocpe())
2021-05-13 20:01:51 +02:00
2021-05-23 21:33:44 +02:00
func _apply_settings_sound_ambient():
2021-06-03 22:18:50 +02:00
$VBoxContainer/ambient_sound/HBoxContainer/data.set_pressed(Setting.get_setting_ambient_sound())
2021-05-13 20:01:51 +02:00
2021-05-29 21:09:10 +02:00
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):
2021-06-03 22:18:50 +02:00
if data.get_item_text(index).split(' x ') == Setting.get_setting_resolution():
2021-05-29 21:09:10 +02:00
data.select(index)
func _apply_settings_fullscreen():
2021-06-03 22:18:50 +02:00
$VBoxContainer/fullscreen/HBoxContainer/data.set_pressed(Setting.get_setting_fullscreen())
2021-05-29 21:09:10 +02:00
2021-05-13 20:01:51 +02:00
func _on_gyroscope_pressed():
2021-06-03 22:18:50 +02:00
Setting.set_setting_gyroscope(int($VBoxContainer/gyroscope/HBoxContainer/data.pressed))
2021-05-23 21:33:44 +02:00
func _on_ambient_sound_pressed():
2021-06-03 22:18:50 +02:00
Setting.set_setting_ambient_sound(int($VBoxContainer/ambient_sound/HBoxContainer/data.pressed))
2021-05-29 21:09:10 +02:00
func _on_langue_item_selected(index):
2021-06-03 22:18:50 +02:00
Setting.set_setting_language(index)
2021-05-29 21:09:10 +02:00
func _on_resolution_item_selected(index):
2021-06-03 22:18:50 +02:00
Setting.set_setting_resolution($VBoxContainer/resolution/VBoxContainer/data.get_item_text(index))
2021-05-29 21:09:10 +02:00
func _on_fullscreen_item_selected():
2021-06-03 22:18:50 +02:00
Setting.set_setting_fullscreen(int($VBoxContainer/fullscreen/HBoxContainer/data.pressed))