370 lines
18 KiB
GDScript
370 lines
18 KiB
GDScript
extends Control
|
|
|
|
signal mute_pressed
|
|
signal musicplayer_pressed
|
|
signal reload_control
|
|
|
|
onready var audiodevice_list = get_node("window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_SOUND/h_box_container_7/audiodevice")
|
|
|
|
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" )
|
|
# $window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_CONTROL/scroll.visible = Config.control_default
|
|
configure_control()
|
|
|
|
|
|
func configure_control():
|
|
Config.msg_debug("<update>" )
|
|
if $window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_CONTROL/h_box_container/sort_by_input.is_pressed():
|
|
configure_control_sort_by_input()
|
|
return
|
|
else:
|
|
configure_control_sort_by_categories()
|
|
|
|
|
|
func configure_control_sort_by_input():
|
|
Config.delete_children($window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_CONTROL/scroll/control)
|
|
var def = {}
|
|
for action in InputMap.get_actions():
|
|
for z in InputMap.get_action_list(action):
|
|
#Config.msg_debug("z:" + str(z))
|
|
var id = str(Config.get_hash_inputevent(z)) + "_" + action
|
|
#Config.msg_debug("<" + id + ">" + str(z))
|
|
def[id] = { 'event': z, 'action': action }
|
|
var defsorted = def.keys()
|
|
defsorted.sort()
|
|
#Config.msg_debug("-------- " + str(defsorted))
|
|
var lastevent = null
|
|
for id in defsorted:
|
|
#Config.msg_debug("z:" + str(id))
|
|
var z = def[id]['event']
|
|
var action = def[id]['action']
|
|
var zhash = Config.get_dict_inputevent(z).hash()
|
|
if zhash != lastevent:
|
|
var separator = HSeparator.new()
|
|
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_CONTROL/scroll/control.add_child( separator )
|
|
lastevent = zhash
|
|
if z is InputEventKey:
|
|
var item = preload( "res://scenes/interfaces/options/option_control_input.tscn" ).instance()
|
|
item.set_param(action, OS.get_scancode_string(z.get_scancode_with_modifiers()), action, z)
|
|
item.connect( "del_pressed", self, "_on_input_box_del_pressed" )
|
|
#print(action,':', z, z.get_scancode_with_modifiers(),' - ', z.get_scancode(), ' - ', z.unicode , ' - ', OS.get_scancode_string(z.get_scancode_with_modifiers()))
|
|
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_CONTROL/scroll/control.add_child( item )
|
|
elif z is InputEventMouseButton:
|
|
var item = preload( "res://scenes/interfaces/options/option_control_input.tscn" ).instance()
|
|
#item.set_label(action, "Mouse Button: " + str(z.get_button_index()))
|
|
item.set_param(action, "Mouse Button: " + Config.get_string_input_mousse_button(z), action, z)
|
|
item.connect( "del_pressed", self, "_on_input_box_del_pressed" )
|
|
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_CONTROL/scroll/control.add_child( item )
|
|
#print(action,':', z, z.get_button_mask(), ' - ', z.get_factor(), ' - ' , z.get_button_index() )
|
|
elif z is InputEventJoypadButton:
|
|
#print(action,':', z, z.get_button_index() )
|
|
var item = preload( "res://scenes/interfaces/options/option_control_input.tscn" ).instance()
|
|
#item.set_label(action, "Joypad Button: " + str(z.get_button_index()))
|
|
item.set_param(action, "Joypad Button: " + Config.get_string_input_joypad_button(z), action, z)
|
|
item.connect( "del_pressed", self, "_on_input_box_del_pressed" )
|
|
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_CONTROL/scroll/control.add_child( item )
|
|
for action in InputMap.get_actions():
|
|
var separator = HSeparator.new()
|
|
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_CONTROL/scroll/control.add_child( separator )
|
|
var control_box = preload( "res://scenes/interfaces/options/option_control_function.tscn" ).instance()
|
|
#control_box.set_label(key)
|
|
control_box.set_param(action, action, true)
|
|
control_box.connect( "add_pressed", self, "_on_control_box_add_pressed" )
|
|
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_CONTROL/scroll/control.add_child( control_box )
|
|
|
|
|
|
func configure_control_sort_by_categories():
|
|
Config.delete_children($window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_CONTROL/scroll/control)
|
|
for action in InputMap.get_actions():
|
|
var control_box = preload( "res://scenes/interfaces/options/option_control_function.tscn" ).instance()
|
|
#control_box.set_label(key)
|
|
control_box.set_param(action, action, false)
|
|
control_box.connect( "add_pressed", self, "_on_control_box_add_pressed" )
|
|
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_CONTROL/scroll/control.add_child( control_box )
|
|
var a = InputMap.get_action_list(action)
|
|
for z in a:
|
|
#print(action,':', z)
|
|
if z is InputEventKey:
|
|
var item = preload( "res://scenes/interfaces/options/option_control_input.tscn" ).instance()
|
|
item.set_param(action, OS.get_scancode_string(z.get_scancode_with_modifiers()), "", z)
|
|
item.connect( "del_pressed", self, "_on_input_box_del_pressed" )
|
|
#print(action,':', z, z.get_scancode_with_modifiers(),' - ', z.get_scancode(), ' - ', z.unicode , ' - ', OS.get_scancode_string(z.get_scancode_with_modifiers()))
|
|
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_CONTROL/scroll/control.add_child( item )
|
|
elif z is InputEventMouseButton:
|
|
var item = preload( "res://scenes/interfaces/options/option_control_input.tscn" ).instance()
|
|
#item.set_label(action, "Mouse Button: " + str(z.get_button_index()))
|
|
item.set_param(action, "Mouse Button: " + Config.get_string_input_mousse_button(z), "", z)
|
|
item.connect( "del_pressed", self, "_on_input_box_del_pressed" )
|
|
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_CONTROL/scroll/control.add_child( item )
|
|
#print(action,':', z, z.get_button_mask(), ' - ', z.get_factor(), ' - ' , z.get_button_index() )
|
|
elif z is InputEventJoypadButton:
|
|
#print(action,':', z, z.get_button_index() )
|
|
var item = preload( "res://scenes/interfaces/options/option_control_input.tscn" ).instance()
|
|
#item.set_label(action, "Joypad Button: " + str(z.get_button_index()))
|
|
item.set_param(action, "Joypad Button: " + Config.get_string_input_joypad_button(z), "", z)
|
|
item.connect( "del_pressed", self, "_on_input_box_del_pressed" )
|
|
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_CONTROL/scroll/control.add_child( item )
|
|
var separator = HSeparator.new()
|
|
$window_dialog/margin_container/v_box_container/tab_container/OPTION_SETTINGS_CONTROL/scroll/control.add_child( separator )
|
|
|
|
|
|
func emit_signal_reload_control():
|
|
emit_signal("reload_control")
|
|
|
|
|
|
func get_input(action: String, texte: String) -> void:
|
|
Config.msg_debug("Start get_input:" + texte + " (" + str(action) + ")")
|
|
var input = load ("res://scenes/interfaces/options/option_input_type.tscn").instance()
|
|
add_child(input)
|
|
# input.set_as_minsize()
|
|
input.set_param(action, self)
|
|
input.popup_centered_clamped()
|
|
Config.msg_debug("End get_input:" + texte + " (" + str(action) + ")")
|
|
|
|
|
|
func _on_control_box_add_pressed(action, command):
|
|
Config.msg_debug("Start Add:" + command)
|
|
#get_input("Appuyer sur votre touche", "Configurer")
|
|
get_input(action, "Appuyer sur votre touche")
|
|
#var input = load("res://scenes/interfaces/options/option_control_input.tscn").instance()
|
|
#input.show()
|
|
Config.msg_debug("End Add:" + command)
|
|
|
|
|
|
func _on_input_box_del_pressed(command, control, inputevent):
|
|
Config.msg_debug("Del:" + command + " " + control)
|
|
Config.del_input(command, inputevent)
|
|
Config.save_config()
|
|
emit_signal_reload_control()
|
|
|
|
|
|
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()
|
|
|
|
|
|
func _on_reload_default_control_pressed():
|
|
Config.msg_debug("<Option/setting> Reload default control")
|
|
#Config.copy_control_system()
|
|
#Config.select_control_config()
|
|
Config.reload_control_system()
|
|
configure_control()
|
|
|
|
|
|
func _on_control_reload_control():
|
|
Config.msg_debug("<Option/setting> Reload control")
|
|
configure_control()
|
|
|
|
|
|
func _on_sort_by_input_toggled(button_pressed):
|
|
Config.msg_debug("<Option/setting> Sort by input : " + str(button_pressed))
|
|
emit_signal_reload_control()
|