2018-08-25 08:05:54 +00:00
|
|
|
extends Container
|
|
|
|
|
|
|
|
signal return_pressed
|
|
|
|
signal font_changed( value )
|
|
|
|
|
|
|
|
func _ready():
|
2020-05-02 18:52:28 +00:00
|
|
|
$Menus/TabContainer/Display/ScrollContainer/VBoxContainer/Fullscreen/CheckBox.pressed = ProjectSettings.get_setting( "display/window/size/fullscreen" )
|
|
|
|
$Menus/TabContainer/Display/ScrollContainer/VBoxContainer/Borderless/CheckBox.pressed = ProjectSettings.get_setting( "display/window/size/borderless" )
|
|
|
|
$Menus/TabContainer/Display/ScrollContainer/VBoxContainer/Resizable/CheckBox.pressed = ProjectSettings.get_setting( "display/window/size/resizable" )
|
|
|
|
$Menus/TabContainer/Display/ScrollContainer/VBoxContainer/CurrentScreen/SpinBox.value = OS.current_screen
|
2018-08-25 08:05:54 +00:00
|
|
|
|
2020-05-02 18:52:28 +00:00
|
|
|
$Menus/TabContainer/connexion/v_box_container/h_box_container4/language.add_item("fr")
|
|
|
|
$Menus/TabContainer/connexion/v_box_container/h_box_container4/language.add_item("en")
|
|
|
|
load_settings()
|
2019-12-14 23:29:30 +00:00
|
|
|
|
2018-08-25 08:05:54 +00:00
|
|
|
|
|
|
|
func _on_font_size_bar_value_changed(value):
|
2020-05-02 18:52:28 +00:00
|
|
|
$Menus/TabContainer/Test/ScrollContainer/VBoxContainer/font_size/font_size_value.text = str( value )
|
|
|
|
$Menus.get_theme().default_font.size = value
|
|
|
|
emit_signal( "font_changed", value )
|
2018-08-25 08:05:54 +00:00
|
|
|
|
|
|
|
func load_settings():
|
|
|
|
|
2020-05-02 18:52:28 +00:00
|
|
|
var config_file = ConfigFile.new()
|
|
|
|
var err = config_file.load( "user://settings.cfg" )
|
|
|
|
if err == ERR_CANT_OPEN or err == ERR_FILE_NOT_FOUND:
|
|
|
|
# On suppose que le fichier n'existe pas encore, donc on le crée.
|
|
|
|
config_file.set_value( "theme", "font_size", 14 )
|
|
|
|
config_file.save( "user://settings.cfg" )
|
|
|
|
elif not err == OK:
|
|
|
|
print("[res://gui_scene/GUI/Settings/Settings.gd:load_settings] Error code when loading config file: ", err)
|
|
|
|
|
|
|
|
global.font_size = config_file.get_value( "theme", "font_size" )
|
|
|
|
if $Menus.get_theme():
|
|
|
|
$Menus.get_theme().default_font.size = global.font_size
|
|
|
|
$Menus/TabContainer/Test/ScrollContainer/VBoxContainer/font_size_bar.value = global.font_size
|
|
|
|
$Menus/TabContainer/Test/ScrollContainer/VBoxContainer/font_size/font_size_value.text = str( global.font_size )
|
|
|
|
|
|
|
|
#var connexion = load("res://assets/Scripts/Config/connexion.gd").new()
|
|
|
|
var script_connexion = preload("res://assets/Scripts/Config/connexion.gd")
|
|
|
|
var connexion = script_connexion.connexion.new()
|
|
|
|
var language = connexion.get_language()
|
|
|
|
$Menus/TabContainer/connexion/v_box_container/h_box_container/register.text = connexion.get_url_register()
|
|
|
|
$Menus/TabContainer/connexion/v_box_container/h_box_container2/connexion.text = connexion.get_url_login()
|
|
|
|
$Menus/TabContainer/connexion/v_box_container/h_box_container3/certificate_valid.pressed = connexion.get_valid_certificate()
|
|
|
|
# language
|
|
|
|
for i in range(0, $Menus/TabContainer/connexion/v_box_container/h_box_container4/language.get_item_count()):
|
|
|
|
if $Menus/TabContainer/connexion/v_box_container/h_box_container4/language.get_item_text(i) == language:
|
|
|
|
$Menus/TabContainer/connexion/v_box_container/h_box_container4/language.select(i)
|
|
|
|
break
|
|
|
|
#$Menus/TabContainer/connexion/v_box_container/h_box_container4/language.
|
|
|
|
#.selected = language
|
|
|
|
#$Menus/TabContainer/connexion/v_box_container/h_box_container4/language.selected
|
2019-12-15 20:52:55 +00:00
|
|
|
|
|
|
|
#func _on_ReturnButton_pressed():
|
|
|
|
# var config_file = ConfigFile.new()
|
|
|
|
# var err = config_file.load( "user://settings.cfg" )
|
|
|
|
# if err:
|
2020-01-05 15:36:41 +00:00
|
|
|
# print("[Settings:_on_ReturnButton_pressed] Error code when loading config file: ", err)
|
2019-12-15 20:52:55 +00:00
|
|
|
# config_file.set_value("theme", "font_size", $Menus.get_theme().default_font.size)
|
|
|
|
# config_file.save( "user://settings.cfg" )
|
|
|
|
# emit_signal( "return_pressed" )
|
2018-08-25 08:05:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
func _on_Title_text_changed(new_text):
|
2020-05-02 18:52:28 +00:00
|
|
|
# ----------------------------------
|
|
|
|
# Changing windows title
|
|
|
|
var new_title = "Khanat"
|
|
|
|
new_text = new_text.strip_edges()
|
|
|
|
if not new_text == "":
|
|
|
|
new_title = new_text
|
|
|
|
new_title += " (" + String(OS.get_window_size().x) + "x" + String(OS.get_window_size().y) + ")"
|
|
|
|
OS.set_window_title( new_title )
|
|
|
|
# ----------------------------------
|
2018-08-25 08:05:54 +00:00
|
|
|
|
|
|
|
func _on_Fullscreen_toggled(button_pressed):
|
2020-05-02 18:52:28 +00:00
|
|
|
if ProjectSettings.has_setting( "display/window/size/fullscreen" ):
|
|
|
|
ProjectSettings.set_setting("display/window/size/fullscreen", button_pressed)
|
|
|
|
OS.window_fullscreen = ProjectSettings.get_setting("display/window/size/fullscreen")
|
2019-12-14 23:29:30 +00:00
|
|
|
|
2018-08-25 08:05:54 +00:00
|
|
|
func _on_Borderless_toggled(button_pressed):
|
2020-05-02 18:52:28 +00:00
|
|
|
if ProjectSettings.has_setting( "display/window/size/borderless" ):
|
|
|
|
ProjectSettings.set_setting("display/window/size/borderless", button_pressed)
|
|
|
|
OS.window_borderless = ProjectSettings.get_setting("display/window/size/borderless")
|
2018-08-25 08:05:54 +00:00
|
|
|
|
|
|
|
func _on_Resizable_toggled(button_pressed):
|
2020-05-02 18:52:28 +00:00
|
|
|
if ProjectSettings.has_setting( "display/window/size/resizable" ):
|
|
|
|
ProjectSettings.set_setting("display/window/size/resizable", button_pressed)
|
|
|
|
OS.window_resizable = ProjectSettings.get_setting("display/window/size/resizable")
|
2018-08-25 08:05:54 +00:00
|
|
|
|
|
|
|
# La fonction existe dans la doc mais le moteur lui ne la reconnait pas,
|
|
|
|
# soit il y a une subtilité quelquepart soit la doc n'est pas à jour.
|
|
|
|
func _on_AlwaysOnTop_toggled(button_pressed):
|
|
|
|
# OS.set_window_always_on_top( button_pressed )
|
2020-05-02 18:52:28 +00:00
|
|
|
pass
|
2018-08-25 08:05:54 +00:00
|
|
|
|
|
|
|
func _on_SpinBox_value_changed(value):
|
2020-05-02 18:52:28 +00:00
|
|
|
OS.current_screen = value
|
2019-12-15 20:52:55 +00:00
|
|
|
|
|
|
|
func _on_ApplyButton_pressed():
|
2020-05-02 18:52:28 +00:00
|
|
|
var config_file = ConfigFile.new()
|
|
|
|
var err = config_file.load( "user://settings.cfg" )
|
|
|
|
if err:
|
|
|
|
print("[res://gui_scene/GUI/Settings/Settings.gd:_on_ApplyButton_pressed] Error code when loading config file: ", err)
|
|
|
|
config_file.set_value("theme", "font_size", $Menus.get_theme().default_font.size)
|
|
|
|
config_file.save( "user://settings.cfg" )
|
|
|
|
|
|
|
|
# Save Connexion
|
|
|
|
var script_connexion = preload("res://assets/Scripts/Config/connexion.gd")
|
|
|
|
var connexion = script_connexion.connexion.new()
|
|
|
|
connexion.set_url_register($Menus/TabContainer/connexion/v_box_container/h_box_container/register.text)
|
|
|
|
connexion.set_url_login($Menus/TabContainer/connexion/v_box_container/h_box_container2/connexion.text)
|
|
|
|
var id = $Menus/TabContainer/connexion/v_box_container/h_box_container4/language.get_selected_id()
|
|
|
|
var language = $Menus/TabContainer/connexion/v_box_container/h_box_container4/language.get_item_text(id)
|
|
|
|
connexion.set_language(language)
|
|
|
|
connexion.set_valid_certificate($Menus/TabContainer/connexion/v_box_container/h_box_container3/certificate_valid.pressed)
|
|
|
|
connexion.save()
|
|
|
|
emit_signal( "return_pressed" )
|
2019-12-15 20:52:55 +00:00
|
|
|
|
|
|
|
func _on_CancelButton_pressed():
|
2020-05-02 18:52:28 +00:00
|
|
|
emit_signal( "return_pressed" )
|
2019-12-15 20:52:55 +00:00
|
|
|
|
|
|
|
func _unhandled_input(event):
|
2020-05-02 18:52:28 +00:00
|
|
|
if event is InputEventKey:
|
|
|
|
if event.pressed and event.scancode == KEY_ESCAPE:
|
|
|
|
emit_signal( "return_pressed" )
|