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

55 lines
2.2 KiB
GDScript
Raw Normal View History

2021-05-13 20:01:51 +02:00
extends Node
func _ready() -> void:
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
func _apply_translation() -> void:
2021-05-29 21:09:10 +02:00
$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() -> void:
var data: ItemList = $VBoxContainer/langue/VBoxContainer/data
2021-05-29 21:09:10 +02:00
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() -> void:
$VBoxContainer/gyroscope/HBoxContainer/data.button_pressed = Setting.get_setting_gyrosocpe()
2021-05-13 20:01:51 +02:00
func _apply_settings_sound_ambient() -> void:
$VBoxContainer/ambient_sound/HBoxContainer/data.button_pressed = Setting.get_setting_ambient_sound()
2021-05-13 20:01:51 +02:00
func _apply_settings_resolution() -> void:
var data: ItemList = $VBoxContainer/resolution/VBoxContainer/data
data.add_item("2560 x 1440", null, true)
data.add_item("1920 x 1080", null, true)
data.add_item("1280 x 720", null, true)
data.add_item("854 x 576", null, true)
2021-05-29 21:09:10 +02:00
for index in range(4):
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() -> void:
$VBoxContainer/fullscreen/HBoxContainer/data.button_pressed = Setting.get_setting_fullscreen()
2021-05-29 21:09:10 +02:00
func _on_gyroscope_pressed() -> void:
Setting.set_setting_gyroscope($VBoxContainer/gyroscope/HBoxContainer/data.button_pressed)
func _on_ambient_sound_pressed() -> void:
Setting.set_setting_ambient_sound($VBoxContainer/ambient_sound/HBoxContainer/data.button_pressed)
2021-05-29 21:09:10 +02:00
func _on_langue_item_selected(index: int) -> void:
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: int) -> void:
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() -> void:
Setting.set_setting_fullscreen($VBoxContainer/fullscreen/HBoxContainer/data.button_pressed)