2021-10-20 17:10:18 +00:00
|
|
|
extends Control
|
|
|
|
|
2021-11-08 04:43:00 +00:00
|
|
|
onready var master_slider = find_node("Master Slider", true, true)
|
|
|
|
onready var music_slider = find_node("Music Slider", true, true)
|
2021-10-21 10:22:42 +00:00
|
|
|
onready var sound_slider = find_node("SFX Slider", true, true)
|
|
|
|
onready var theme_buttons = find_node("Buttons", true, true).get_children()
|
|
|
|
|
2021-11-14 08:50:39 +00:00
|
|
|
var light_theme = load("res://light_theme.tres")
|
|
|
|
var dark_theme = load("res://dark_theme.tres")
|
2021-10-21 10:22:42 +00:00
|
|
|
|
2021-10-20 17:10:18 +00:00
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
func _ready():
|
2021-10-31 10:46:49 +00:00
|
|
|
OptionsController.load_options()
|
2021-10-21 06:24:27 +00:00
|
|
|
find_next_valid_focus().grab_focus()
|
2021-11-14 06:30:18 +00:00
|
|
|
master_slider.value = db2linear(OptionsController.get_mas_volume())
|
|
|
|
music_slider.value = db2linear(OptionsController.get_mus_volume())
|
|
|
|
sound_slider.value = db2linear(OptionsController.get_sfx_volume())
|
2021-11-14 08:50:39 +00:00
|
|
|
|
|
|
|
var _errno = 0;
|
|
|
|
_errno += OptionsController.connect("change_theme", self, "_on_change_theme")
|
|
|
|
_on_change_theme(OptionsController.get_theme())
|
2021-10-20 17:10:18 +00:00
|
|
|
|
|
|
|
func _on_Button_pressed():
|
2021-11-08 02:33:07 +00:00
|
|
|
AudioBus.emit_signal("button_clicked")
|
2021-10-20 17:10:18 +00:00
|
|
|
queue_free()
|
2021-11-08 02:33:07 +00:00
|
|
|
#MessageBus.emit_signal("change_scene", "Title")
|
2021-10-21 10:22:42 +00:00
|
|
|
|
2021-11-08 04:43:00 +00:00
|
|
|
func _on_Master_Slider_value_changed(value):
|
2021-11-14 06:30:18 +00:00
|
|
|
value = linear2db(value)
|
2021-11-08 02:33:07 +00:00
|
|
|
AudioBus.emit_signal("button_clicked")
|
2021-11-08 05:11:19 +00:00
|
|
|
OptionsController.set_vol(value, "mas_vol")
|
2021-10-21 10:22:42 +00:00
|
|
|
|
2021-11-08 04:43:00 +00:00
|
|
|
func _on_Music_Slider_value_changed(value):
|
2021-11-14 06:30:18 +00:00
|
|
|
value = linear2db(value)
|
2021-11-08 04:43:00 +00:00
|
|
|
AudioBus.emit_signal("button_clicked")
|
2021-11-08 05:11:19 +00:00
|
|
|
OptionsController.set_vol(value, "mus_vol")
|
2021-10-21 10:22:42 +00:00
|
|
|
|
2021-11-08 04:43:00 +00:00
|
|
|
func _on_SFX_Slider_value_changed(value):
|
2021-11-14 06:30:18 +00:00
|
|
|
value = linear2db(value)
|
2021-11-08 04:43:00 +00:00
|
|
|
AudioBus.emit_signal("button_clicked")
|
2021-11-08 05:11:19 +00:00
|
|
|
OptionsController.set_vol(value, "sfx_vol")
|
2021-11-08 04:43:00 +00:00
|
|
|
|
2021-10-21 10:22:42 +00:00
|
|
|
func _on_Light_pressed():
|
2021-11-08 02:33:07 +00:00
|
|
|
AudioBus.emit_signal("button_clicked")
|
2021-10-21 10:22:42 +00:00
|
|
|
OptionsController.set_theme("light")
|
|
|
|
|
|
|
|
func _on_Dark_pressed():
|
2021-11-08 02:33:07 +00:00
|
|
|
AudioBus.emit_signal("button_clicked")
|
2021-10-21 10:22:42 +00:00
|
|
|
OptionsController.set_theme("dark")
|
2021-11-14 08:50:39 +00:00
|
|
|
|
|
|
|
func _on_change_theme(theme):
|
|
|
|
if theme == "light":
|
|
|
|
self.set_theme(light_theme)
|
|
|
|
elif theme == "dark":
|
|
|
|
self.set_theme(dark_theme)
|