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

186 lines
9.4 KiB
GDScript3
Raw Normal View History

extends Control
signal mute_pressed
var slots_number = 0
var slots = {}
var firstime = 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()
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_add_music_pressed():
pass # Replace with function body.
$file_dialog.show()
func _on_file_dialog_files_selected(paths):
print("multi files")
for path in paths:
var found = false
for slot in self.slots:
if self.slots[slot].music_filename == path:
found = true
continue
if found:
continue
var music_box = preload( "res://scenes/interfaces/options/option_settings_music_box.tscn" ).instance()
music_box.get_node( "label" ).text = path
#music_box.enable.pressed = true
#music_box.zone = "All"
music_box.slot = self.slots_number
music_box.music_filename = path
#creature_box.connect( "select_pressed", self, "_on_creature_box_select_pressed" )
music_box.connect( "delete_pressed", self, "_on_music_box_delete_pressed" )
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/scroll_container/list_music.add_child(music_box)
MusicManager.add_music(path)
self.slots[ self.slots_number ] = music_box
self.slots_number += 1
func _on_music_box_delete_pressed( slot ):
if self.slots[ slot ].music_filename:
#var dir = Directory.new()
#dir.remove( "user://creatures/" + self.slots[ slot ].creature_filename )
pass
self.slots[ slot ].queue_free()
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):
var valueint = int(value)
Config.set_font_size(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("")
MusicManager.set_sound_mute(button_pressed)
emit_signal( "mute_pressed" )
#func _on_control_mute_pressed():
# update_mute()