khanat-client/scenes/interfaces/options/option_settings.gd

225 lines
11 KiB
GDScript

extends Control
signal mute_pressed
signal musicplayer_pressed
onready var audiodevice_list = get_node("window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container_7/audiodevice")
#var slots_number = 0
#var slots = {}
var firstime = false
var disable_execution_mute:bool = false
# Called when the node enters the scene tree for the first time.
func _ready():
# default video configuration
if Config.video_default:
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_VIDEO/h_box_container_8/default.pressed = true
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_VIDEO/settings_video.visible = false
else:
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_VIDEO/h_box_container_8/default.pressed = false
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_VIDEO/settings_video.visible = true
# Font size
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_VIDEO/h_box_container_9/font.value = Config.font_size
# window fullscreen
if ProjectSettings.has_setting( "display/window/size/fullscreen" ):
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_VIDEO/settings_video/h_box_container/fullscreen.pressed = Config.window_fullscreen
# ProjectSettings.get_setting( "display/window/size/fullscreen" )
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_VIDEO/settings_video/h_box_container/fullscreen.disabled = false
else:
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_VIDEO/settings_video/h_box_container/fullscreen.disabled = true
# window borderless
if ProjectSettings.has_setting( "display/window/size/borderless" ):
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_VIDEO/settings_video/h_box_container_2/borderless.pressed = Config.window_borderless
# ProjectSettings.get_setting( "display/window/size/borderless" )
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_VIDEO/settings_video/h_box_container_2/borderless.disabled = false
else:
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_VIDEO/settings_video/h_box_container_2/borderless.disabled = true
# window resizable
if ProjectSettings.has_setting( "display/window/size/resizable" ):
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_VIDEO/settings_video/h_box_container_3/resizable.pressed = Config.window_resizable
# ProjectSettings.get_setting( "display/window/size/resizable" )
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_VIDEO/settings_video/h_box_container_3/resizable.disabled = false
else:
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_VIDEO/settings_video/h_box_container_3/resizable.disabled = true
# Screen number
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_VIDEO/settings_video/h_box_container_4/screen.min_value = 0
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_VIDEO/settings_video/h_box_container_4/screen.max_value = OS.get_screen_count() - 1
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_VIDEO/settings_video/h_box_container_4/screen.value = OS.current_screen
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_VIDEO/settings_video/h_box_container_4/screen.editable = true
# Screen orientation
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_VIDEO/settings_video/h_box_container_5/orientation.value = OS.get_screen_orientation()
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_VIDEO/settings_video/h_box_container_5/orientation.editable = true
# always_on_top
if ProjectSettings.has_setting( "display/window/size/always_on_top" ):
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_VIDEO/settings_video/h_box_container_6/always_on_top.pressed = OS.is_keep_screen_on()
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_VIDEO/settings_video/h_box_container_6/always_on_top.disabled = false
else:
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_VIDEO/settings_video/h_box_container_6/always_on_top.disabled = true
# window maximized
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_VIDEO/settings_video/h_box_container_7/window_maximized.pressed = Config.window_maximized
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_VIDEO/settings_video/h_box_container_7/window_maximized.disabled = false
# Level sound
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container_3/sound_lvl_global.value = Config.sound_lvl_global
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container_6/sound_lvl_music.value = Config.sound_lvl_music
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container_4/sound_lvl_effect.value = Config.sound_lvl_effect
# Mute
#$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container_2/mute.pressed = Config.mute
update_mute()
# List audio device
for item in AudioServer.get_device_list():
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container_7/audiodevice.add_item(item)
#audiodevice_list.add_item(item)
var device = AudioServer.get_device()
for i in range(audiodevice_list.get_item_count()):
if device == audiodevice_list.get_item_text(i):
audiodevice_list.select(i)
break
MusicManager.connect("musicplayer_pressed", self, "_on_signal_musicplayer_pressed")
#$option.connect("mute_pressed", self, "update_mute")
MusicManager.connect("mute_pressed", self, "_on_signal_mute_pressed")
MusicManager.connect_ext_func("musicplayer_pressed", self, "_on_signal_musicplayer_pressed")
MusicManager.connect_ext_func("mute_pressed", self, "_on_signal_mute_pressed" )
func connect_ext_func( signal_name, target , function_target):
Config.msg_debug("Connect external [signal:" + signal_name + ", func:" + function_target + "]")
target.connect( signal_name, self, function_target )
func update_mute():
Config.msg_debug("")
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container_2/mute.pressed = Config.mute
func _on_fullscreen_toggled(button_pressed):
Config.set_window_fullscreen(button_pressed)
func _on_borderless_toggled(button_pressed):
Config.set_window_borderless(button_pressed)
func _on_resizable_toggled(button_pressed):
Config.set_window_resizable(button_pressed)
func _on_window_maximized_toggled(button_pressed):
Config.set_window_maximized(button_pressed)
func _on_screen_value_changed(value):
Config.set_current_screen(value)
# SCREEN_ORIENTATION_LANDSCAPE = 0 Landscape screen orientation.
# SCREEN_ORIENTATION_PORTRAIT = 1 Portrait screen orientation.
# SCREEN_ORIENTATION_REVERSE_LANDSCAPE = 2 Reverse landscape screen orientation.
# SCREEN_ORIENTATION_REVERSE_PORTRAIT = 3 Reverse portrait screen orientation.
# SCREEN_ORIENTATION_SENSOR_LANDSCAPE = 4 Uses landscape or reverse landscape based on the hardware sensor.
# SCREEN_ORIENTATION_SENSOR_PORTRAIT = 5 Uses portrait or reverse portrait based on the hardware sensor.
# SCREEN_ORIENTATION_SENSOR = 6 Uses most suitable orientation based on
func _on_orientation_value_changed(value):
# display/window/handheld/orientation
#print(OS.screen_orientation)
#print(ProjectSettings.get_setting("display/window/handheld/orientation"))
#if ProjectSettings.has_setting( "display/window/handheld/orientation" ):
# ProjectSettings.set_setting("display/window/handheld/orientation", value)
##OS.screen_orientation = value
#print(OS.get_screen_orientation())
Config.set_screen_orientation(value)
#OS.set_screen_orientation(value)
func _on_always_on_top_toggled(button_pressed):
Config.set_window_always_on_top(button_pressed)
func _on_default_toggled(button_pressed):
if button_pressed:
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_VIDEO/h_box_container_8/default.pressed = true
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_VIDEO/settings_video.visible = false
Config.enable_window_default()
else:
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_VIDEO/h_box_container_8/default.pressed = false
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_VIDEO/settings_video.visible = true
Config.disable_window_default()
Config.set_video_default(button_pressed)
func _on_font_value_changed(value):
Config.set_font_size(int(value))
func _on_sound_lvl_global_value_changed(value):
MusicManager.set_level_global(int(value))
func _on_sound_lvl_music_value_changed(value):
MusicManager.set_level_music(int(value))
func _on_sound_lvl_effect_value_changed(value):
MusicManager.set_level_effect(int(value))
func _on_ok_pressed():
$file_dialog.hide()
$window_dialog.hide()
Config.save_config()
func _on_window_dialog_hide():
$file_dialog.hide()
if firstime:
Config.save_config()
func _on_window_dialog_draw():
firstime = true
func _on_mute_toggled(button_pressed):
Config.msg_debug("Option/Setting push mute")
if self.disable_execution_mute:
return
MusicManager.set_sound_mute(button_pressed)
emit_signal( "mute_pressed" )
func _on_button_pressed():
MusicManager.open()
func _on_musicplayer_pressed():
Config.msg_debug("musicplayer_pressed")
Config.set_playermusic(not Config.get_playermusic())
Config.save_config()
emit_signal( "musicplayer_pressed")
func _on_audiodevice_item_selected(index):
AudioServer.set_device(audiodevice_list.get_item_text(index))
func _on_control_musicplayer_pressed():
Config.msg_debug("Option/setting signal received musicplayer")
func _on_control_mute_pressed():
Config.msg_debug("<Option/setting> signal received mute")
func _on_signal_mute_pressed():
Config.msg_debug("<Option/setting> signal received mute")
self.disable_execution_mute = true
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container_2/mute.pressed = Config.mute
self.disable_execution_mute = false
Config.msg_debug("<Option/setting> signal received mute : End")
func _on_signal_musicplayer_pressed():
Config.msg_debug("<Option/setting> signal received musicplayer")
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container_5/musicplayer.pressed = Config.get_playermusic()