Implementing first use of configuration file with music volume

This commit is contained in:
yannk 2022-04-22 09:58:30 +02:00
parent 3ce18ecbcd
commit 52d8bdf306
3 changed files with 6 additions and 6 deletions

View file

@ -42,8 +42,10 @@ func _ready():
# var t = linear2db(0.0)
# var u = db2linear($Music.get_volume_db())
# Common.msg_debug("volume :" + str(u))
$Window/VBox/Tab/Mixer/MusicLevel/music.set_value( int(db2linear($Music.get_volume_db()) * float(user_settings.configuration["sound"]["music_volume"])))
$Window/VBox/Tab/Mixer/MusicLevel/Value.set_text(str(int(db2linear($Music.get_volume_db()) * float(user_settings.configuration["sound"]["music_volume"]))))
var music_volume = float(user_settings.configuration["sound"]["music_volume"])
$Music.set_volume_db(linear2db(music_volume/100.0))
$Window/VBox/Tab/Mixer/MusicLevel/music.set_value( int(db2linear($Music.get_volume_db()) * 100))
$Window/VBox/Tab/Mixer/MusicLevel/Value.set_text(str(int(db2linear($Music.get_volume_db()) * 100)))
var bus_name = $Music.get_bus()
Common.msg_debug("bus_name: " + str(bus_name))
var bus_id = AudioServer.get_bus_index(bus_name)

View file

@ -6,6 +6,7 @@
script = ExtResource( "1_dltpv" )
[node name="Music" type="AudioStreamPlayer" parent="."]
volume_db = 23.803
[node name="EndMusic" type="Timer" parent="."]

View file

@ -3,11 +3,8 @@ extends Node
var cfg_path = "user://settings.cfg"
@onready var configuration = get_settings()
# Called when the node enters the scene tree for the first time.
func _ready():
pass
func save():
Common.msg_debug("Save to config file : %s/%s" % [OS.get_user_data_dir(), cfg_path.replace("user://", "")])
var file = ConfigFile.new()
for section in configuration.keys():
for key in configuration[section].keys():