Ajou t de la sauvegarde de la police dans un fichier cfg.

This commit is contained in:
osquallo 2018-07-28 10:42:53 +02:00
parent 2ffe407827
commit 5130eaffe6
5 changed files with 27 additions and 11 deletions

View file

@ -19,7 +19,7 @@ _sections_unfolded = [ "Font", "Settings" ]
default_font = SubResource( 1 )
[node name="GUI" type="MarginContainer" index="0"]
[node name="GUI" type="MarginContainer"]
anchor_left = 0.0
anchor_top = 0.0

View file

@ -12,7 +12,7 @@
[ext_resource path="res://scenes/GUI/HUD/trauma.gd" type="Script" id=10]
[ext_resource path="res://scenes/GUI/HUD/douleur.gd" type="Script" id=11]
[node name="HUD" type="MarginContainer" index="0"]
[node name="HUD" type="MarginContainer"]
anchor_left = 0.0
anchor_top = 0.0

View file

@ -117,12 +117,6 @@ func load_from_file( config_file ):
func save_to_file( config_file ):
print( "saving "+ self.name +" in file"+ str(config_file) )
print( "... position: "+ str(self.rect_position) )
print( "... size: "+ str(self.rect_size) )
print( "......" )
print( "" )
config_file.set_value(self.name, "position", self.rect_position)
config_file.set_value(self.name, "size", current_rect_size)
if $VBoxContainer/Content.visible:

View file

@ -9,14 +9,37 @@ func _ready():
$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
$Menus/TabContainer/Test/ScrollContainer/VBoxContainer/font_size/font_size_value.text = str( $Menus/TabContainer/Test/ScrollContainer/VBoxContainer/font_size_bar.value )
load_settings()
func _on_font_size_bar_value_changed(value):
$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 )
func load_settings():
var config_file = ConfigFile.new()
var err = config_file.load( "user://settings.cfg" )
if err:
print("Error code when loading config file: ", err)
$Menus.get_theme().default_font.size = config_file.get_value( "theme", "font_size" )
$Menus/TabContainer/Test/ScrollContainer/VBoxContainer/font_size_bar.value = config_file.get_value( "theme", "font_size" )
$Menus/TabContainer/Test/ScrollContainer/VBoxContainer/font_size/font_size_value.text = str( $Menus/TabContainer/Test/ScrollContainer/VBoxContainer/font_size_bar.value )
func _on_ReturnButton_pressed():
var config_file = ConfigFile.new()
var err = config_file.load( "user://settings.cfg" )
if err:
print("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" )
emit_signal( "return_pressed" )

View file

@ -148,7 +148,7 @@ use_filter = false
font_data = ExtResource( 2 )
_sections_unfolded = [ "Font", "Settings" ]
[node name="Settings" type="MarginContainer"]
[node name="Settings" type="MarginContainer" index="0"]
anchor_left = 0.0
anchor_top = 0.0
@ -1609,7 +1609,6 @@ margin_bottom = 446.0
[node name="Footer" type="HBoxContainer" parent="Menus" index="2"]
editor/display_folded = true
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 0.0