project_teddy/scripts/settings.gd

66 lines
1.6 KiB
GDScript

extends Control
@export var audio_bus_name := "Master"
@onready var _bus := AudioServer.get_bus_index(audio_bus_name)
@onready var main:Window = $"/root"
func _ready():
if get_window().get_mode() == Window.Mode.MODE_FULLSCREEN:
$fullscreenBox.button_pressed = true
if main.get_content_scale_aspect() == 0:
$wideBox.button_pressed = true
func _on_h_slider_ready():
var slider = $h_slider
slider.value = Global.mouseSensitivity
func _process(delta):
pass
func _on_h_slider_value_changed(value):
Global.mouseSensitivity = value
Global.save_data()
func _on_button_pressed():
self.queue_free()
func _on_volume_slider_value_changed(value):
Global.volumeModifer = value
AudioServer.set_bus_volume_db(_bus, linear_to_db(value))
Global.save_data()
func _on_volume_slider_ready():
var slider = $volumeSlider
slider.value = Global.volumeModifer
func _on_fullscreen_box_pressed():
if $fullscreenBox.button_pressed == true:
get_window().set_mode(Window.Mode.MODE_FULLSCREEN)
elif $fullscreenBox.button_pressed == false:
get_window().set_mode(Window.Mode.MODE_WINDOWED)
func _on_wide_box_pressed():
if $wideBox.button_pressed == true:
main.set_content_scale_aspect(Window.CONTENT_SCALE_ASPECT_IGNORE)
Global.stretchUI = true
if $wideBox.button_pressed == false:
main.set_content_scale_aspect(Window.CONTENT_SCALE_ASPECT_KEEP)
Global.stretchUI = false
Global.save_data()
func _on_health_options_ready():
$healthOptions.add_item("classic", 0)
$healthOptions.add_item("modern", 1)
$healthOptions.selected = Global.healthStyle
func _on_health_options_item_selected(index):
Global.healthStyle = index
Global.save_data()