2023-04-09 12:00:52 +00:00
|
|
|
extends Node
|
|
|
|
|
2023-04-10 20:46:15 +00:00
|
|
|
@export var back_button : Control
|
|
|
|
@export var tab_container : TabContainer
|
|
|
|
@export var bottom_item_video : Control
|
|
|
|
@export var bottom_item_audio : Control
|
|
|
|
@export var bottom_item_controls : Control
|
|
|
|
|
2023-04-11 19:03:25 +00:00
|
|
|
@export var remap_controller : RemapController
|
|
|
|
|
2023-04-09 12:00:52 +00:00
|
|
|
@export var display_options_button : OptionButton
|
|
|
|
@export var vsync_toggle : CheckButton
|
|
|
|
@export var resolutions_options_button : OptionButton
|
|
|
|
|
2023-04-10 20:46:15 +00:00
|
|
|
var on_back : Callable
|
|
|
|
|
2023-04-09 12:00:52 +00:00
|
|
|
# Audio Settings UI References
|
|
|
|
@export var master_volume_slider : Slider
|
|
|
|
@export var music_volume_slider : Slider
|
|
|
|
@export var sfx_volume_slider : Slider
|
|
|
|
|
|
|
|
# Engine Callbacks
|
|
|
|
func _ready():
|
2023-04-10 20:46:15 +00:00
|
|
|
back_button.grab_focus()
|
|
|
|
back_button.focus_neighbor_top = bottom_item_video.get_path()
|
|
|
|
|
2023-04-09 13:04:49 +00:00
|
|
|
add_resolution_items()
|
2023-04-09 12:00:52 +00:00
|
|
|
display_options_button.select(Save.game_data.display_mode)
|
|
|
|
GlobalSettings.set_display_mode(Save.game_data.display_mode)
|
|
|
|
vsync_toggle.set_pressed_no_signal(Save.game_data.vsync_on)
|
|
|
|
GlobalSettings.toggle_vsync(Save.game_data.vsync_on)
|
2023-04-11 14:54:04 +00:00
|
|
|
if Save.game_data.display_mode == DisplayServer.WINDOW_MODE_FULLSCREEN or Save.game_data.display_mode == DisplayServer.WINDOW_MODE_EXCLUSIVE_FULLSCREEN:
|
|
|
|
GlobalSettings.set_resolution(Save.game_data.current_resolution_index)
|
2023-04-09 13:04:49 +00:00
|
|
|
resolutions_options_button.select(Save.game_data.current_resolution_index)
|
2023-04-09 12:00:52 +00:00
|
|
|
master_volume_slider.value = Save.game_data.master_volume
|
|
|
|
GlobalSettings.update_master_volume(Save.game_data.master_volume)
|
|
|
|
music_volume_slider.value = Save.game_data.music_volume
|
|
|
|
GlobalSettings.update_music_volume(Save.game_data.music_volume)
|
|
|
|
sfx_volume_slider.value = Save.game_data.sfx_volume
|
|
|
|
GlobalSettings.update_sfx_volume(Save.game_data.sfx_volume)
|
|
|
|
pass
|
2023-04-10 20:46:15 +00:00
|
|
|
|
2023-04-10 21:31:07 +00:00
|
|
|
func _process(_delta):
|
2023-04-10 20:46:15 +00:00
|
|
|
update_change_tab()
|
|
|
|
pass
|
|
|
|
|
|
|
|
func update_change_tab():
|
2023-04-11 19:03:25 +00:00
|
|
|
if(remap_controller.is_remapping): return
|
2023-04-10 20:46:15 +00:00
|
|
|
var do_left = Input.is_action_just_pressed("ui_tab_left")
|
|
|
|
var do_right = Input.is_action_just_pressed("ui_tab_right")
|
|
|
|
|
|
|
|
if do_left:
|
|
|
|
var new_rab = tab_container.current_tab - 1
|
|
|
|
tab_container.current_tab = new_rab if new_rab >= 0 else tab_container.get_tab_count() - 1
|
|
|
|
if do_right:
|
|
|
|
var new_rab = tab_container.current_tab + 1
|
|
|
|
tab_container.current_tab = new_rab if new_rab < tab_container.get_tab_count() else 0
|
|
|
|
|
|
|
|
if do_left or do_right:
|
|
|
|
match tab_container.current_tab:
|
|
|
|
0: back_button.focus_neighbor_top = bottom_item_video.get_path()
|
|
|
|
1: back_button.focus_neighbor_top = bottom_item_audio.get_path()
|
|
|
|
2: back_button.focus_neighbor_top = bottom_item_controls.get_path()
|
|
|
|
back_button.grab_focus()
|
|
|
|
pass
|
2023-04-09 12:00:52 +00:00
|
|
|
|
2023-04-09 13:04:49 +00:00
|
|
|
func add_resolution_items():
|
|
|
|
for key in GlobalSettings.resolutions_dictionary.keys():
|
|
|
|
resolutions_options_button.add_item(key)
|
|
|
|
|
2023-04-09 12:00:52 +00:00
|
|
|
# Other Buttons
|
|
|
|
func _on_back_pressed():
|
2023-04-10 22:27:26 +00:00
|
|
|
Save.save_data()
|
2023-04-10 20:46:15 +00:00
|
|
|
on_back.call()
|
2023-04-09 12:00:52 +00:00
|
|
|
queue_free()
|
|
|
|
pass
|
|
|
|
|
|
|
|
# Video Settings
|
|
|
|
func _on_display_mode_options_item_selected(index):
|
|
|
|
GlobalSettings.set_display_mode(index)
|
|
|
|
pass
|
|
|
|
|
|
|
|
func _on_vsync_button_toggled(button_pressed):
|
|
|
|
GlobalSettings.toggle_vsync(button_pressed)
|
|
|
|
pass
|
|
|
|
|
|
|
|
func _on_resolutions_options_item_selected(index):
|
2023-04-09 13:04:49 +00:00
|
|
|
GlobalSettings.set_resolution(index)
|
2023-04-09 12:00:52 +00:00
|
|
|
pass
|
|
|
|
|
|
|
|
# Audio Settings
|
|
|
|
func _on_master_volume_slider_value_changed(value):
|
|
|
|
GlobalSettings.update_master_volume(value)
|
|
|
|
pass
|
|
|
|
|
|
|
|
func _on_music_vol_slider_value_changed(value):
|
|
|
|
GlobalSettings.update_music_volume(value)
|
|
|
|
pass
|
|
|
|
|
|
|
|
func _on_sfx_vol_slider_value_changed(value):
|
|
|
|
GlobalSettings.update_sfx_volume(value)
|
|
|
|
pass
|