correct import setting

This commit is contained in:
AleaJactaEst 2022-05-24 23:32:25 +02:00
parent fa5bc6b1a6
commit 0b975133e7
70 changed files with 460 additions and 50 deletions

View file

@ -0,0 +1,3 @@
source_md5="166af68e564c805f182848ff1e03b879"
dest_md5="0facff8907e454c156eef67ac16fb1ca"

View file

@ -0,0 +1,3 @@
source_md5="ced507b169c48f6b02bc7ef3e6c25128"
dest_md5="165a0c2222abb4c0aad8f8aee63a307a"

View file

@ -0,0 +1,3 @@
source_md5="dd139845ea7dae77c85940b5d36a3a71"
dest_md5="831f6bc1a958973ba8e7c2acbdc7335e"

View file

@ -0,0 +1,3 @@
source_md5="520d1bc4ecdf036923ed4ab4729c7393"
dest_md5="733ff8c4b9dd2d21b4ce103fc200ab54"

View file

@ -0,0 +1,3 @@
source_md5="ee894c5daac177cf9d150e9d4532e9cb"
dest_md5="116484e0b82e8278c043d4d19ecc64ce"

View file

@ -0,0 +1,3 @@
source_md5="a859a9c57e6601a3a36f225a2a4e1370"
dest_md5="64a1fc903735b95de5bf1fef005706b8"

View file

@ -0,0 +1,3 @@
source_md5="3a3513acf139505d53e5b160ae8f9666"
dest_md5="fdc809abd8ea0ce25523bb29edda7d73"

View file

@ -0,0 +1,3 @@
source_md5="bbd32a0ae64acd9ba5aedfc2cfcec6c1"
dest_md5="43201e5334e71b36cb5ef341ad87fd84"

View file

@ -0,0 +1,3 @@
source_md5="12f4f13050fda086ff9633168becbe86"
dest_md5="0db268aec5e6828b9cfde7a506c4d180"

View file

@ -0,0 +1,3 @@
source_md5="707a76d7a7d3f084cbe956f18e679b8f"
dest_md5="fc393c34ec1d5d25c00ccf444f74f91a"

View file

@ -0,0 +1,3 @@
source_md5="1e838b682b3e7dcc7a6bd1ce670e31a0"
dest_md5="24b6c9a28fa254484e8db3ba7f699ef2"

View file

@ -0,0 +1,3 @@
source_md5="96b0569fc5157c8177e9f0f3c033b4a0"
dest_md5="b1d0164952d388b4a133fbfabdc8f16a"

View file

@ -0,0 +1,3 @@
source_md5="42cf07d21ce7bdf8b3d40ac4257554a4"
dest_md5="73d9f017481493a0afe300ea0fbc4e9c"

View file

@ -0,0 +1,3 @@
source_md5="b4daca848ab3d13ea5d29f12ca2ea7f3"
dest_md5="70ffc3784733643fa987cb4a6b841fa6"

View file

@ -0,0 +1,3 @@
source_md5="142a41cf855eb73e2a5ba051dacea413"
dest_md5="b8668b2ebc9c99cf2d1fd5ec1140cfdc"

View file

@ -0,0 +1,3 @@
source_md5="1b2ddd55e3a10534764b3c666303af0c"
dest_md5="308f3fa709d8b424e0a8c22529afd0e0"

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,16 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOGGVorbis"
uid="uid://jvy2mlfu801v"
path="res://.godot/imported/Khanat - 1 - Kirun Chante (et le Khanat ecoute).ogg-941a50f1c2de22f2e8cfa5da02cec04d.oggvorbisstr"
[deps]
source_file="res://music/Les Chemins du Khanat/Khanat - 1 - Kirun Chante (et le Khanat ecoute).ogg"
dest_files=["res://.godot/imported/Khanat - 1 - Kirun Chante (et le Khanat ecoute).ogg-941a50f1c2de22f2e8cfa5da02cec04d.oggvorbisstr"]
[params]
loop=true
loop_offset=0

View file

@ -0,0 +1,16 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOGGVorbis"
uid="uid://pswlcect65nf"
path="res://.godot/imported/Khanat - 10 - La Crypte.ogg-bfbe29611446d09b046304f8a43c827c.oggvorbisstr"
[deps]
source_file="res://music/Les Chemins du Khanat/Khanat - 10 - La Crypte.ogg"
dest_files=["res://.godot/imported/Khanat - 10 - La Crypte.ogg-bfbe29611446d09b046304f8a43c827c.oggvorbisstr"]
[params]
loop=true
loop_offset=0

View file

@ -0,0 +1,16 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOGGVorbis"
uid="uid://c741ram8tv2k6"
path="res://.godot/imported/Khanat - 11 - Les Monts De Givre.ogg-70168176f537c4affe3fbc4d54849587.oggvorbisstr"
[deps]
source_file="res://music/Les Chemins du Khanat/Khanat - 11 - Les Monts De Givre.ogg"
dest_files=["res://.godot/imported/Khanat - 11 - Les Monts De Givre.ogg-70168176f537c4affe3fbc4d54849587.oggvorbisstr"]
[params]
loop=true
loop_offset=0

View file

@ -0,0 +1,16 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOGGVorbis"
uid="uid://dycreylxo4qkf"
path="res://.godot/imported/Khanat - 12 - Ra Contre Ra (Reve Contre Reve).ogg-0b1930b50c800892c57ab9f835e02d04.oggvorbisstr"
[deps]
source_file="res://music/Les Chemins du Khanat/Khanat - 12 - Ra Contre Ra (Reve Contre Reve).ogg"
dest_files=["res://.godot/imported/Khanat - 12 - Ra Contre Ra (Reve Contre Reve).ogg-0b1930b50c800892c57ab9f835e02d04.oggvorbisstr"]
[params]
loop=true
loop_offset=0

Binary file not shown.

View file

@ -0,0 +1,16 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOGGVorbis"
uid="uid://dpvvxwae1khxs"
path="res://.godot/imported/Khanat - 13 - Le Delta.ogg-83c2e2eb5a90b54ab9a9dba6d2186f10.oggvorbisstr"
[deps]
source_file="res://music/Les Chemins du Khanat/Khanat - 13 - Le Delta.ogg"
dest_files=["res://.godot/imported/Khanat - 13 - Le Delta.ogg-83c2e2eb5a90b54ab9a9dba6d2186f10.oggvorbisstr"]
[params]
loop=true
loop_offset=0

View file

@ -0,0 +1,16 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOGGVorbis"
uid="uid://dkmn1jy7lweb"
path="res://.godot/imported/Khanat - 14 - Combat Theme 2.ogg-d3e536c693061c729a1bb7163c654786.oggvorbisstr"
[deps]
source_file="res://music/Les Chemins du Khanat/Khanat - 14 - Combat Theme 2.ogg"
dest_files=["res://.godot/imported/Khanat - 14 - Combat Theme 2.ogg-d3e536c693061c729a1bb7163c654786.oggvorbisstr"]
[params]
loop=true
loop_offset=0

View file

@ -0,0 +1,16 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOGGVorbis"
uid="uid://txrigu4xkd47"
path="res://.godot/imported/Khanat - 15 - La Mort N'Est Pas Une Fin (Version Longue).ogg-0f7dac4baa625580ea7bd42bec70d902.oggvorbisstr"
[deps]
source_file="res://music/Les Chemins du Khanat/Khanat - 15 - La Mort N'Est Pas Une Fin (Version Longue).ogg"
dest_files=["res://.godot/imported/Khanat - 15 - La Mort N'Est Pas Une Fin (Version Longue).ogg-0f7dac4baa625580ea7bd42bec70d902.oggvorbisstr"]
[params]
loop=true
loop_offset=0

View file

@ -0,0 +1,16 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOGGVorbis"
uid="uid://0s55lw4xnd64"
path="res://.godot/imported/Khanat - 16 - Credit Theme.ogg-850c2ec6983021515fde8a708c25f6fb.oggvorbisstr"
[deps]
source_file="res://music/Les Chemins du Khanat/Khanat - 16 - Credit Theme.ogg"
dest_files=["res://.godot/imported/Khanat - 16 - Credit Theme.ogg-850c2ec6983021515fde8a708c25f6fb.oggvorbisstr"]
[params]
loop=true
loop_offset=0

View file

@ -0,0 +1,16 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOGGVorbis"
uid="uid://n3pmmuo6oqnb"
path="res://.godot/imported/Khanat - 2 - Khanat Main Theme (Le Petit Pantin Au Coeur De Glace Remix).ogg-2e47137ca325f1d311012d8b19116c1d.oggvorbisstr"
[deps]
source_file="res://music/Les Chemins du Khanat/Khanat - 2 - Khanat Main Theme (Le Petit Pantin Au Coeur De Glace Remix).ogg"
dest_files=["res://.godot/imported/Khanat - 2 - Khanat Main Theme (Le Petit Pantin Au Coeur De Glace Remix).ogg-2e47137ca325f1d311012d8b19116c1d.oggvorbisstr"]
[params]
loop=true
loop_offset=0

View file

@ -0,0 +1,16 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOGGVorbis"
uid="uid://cfteviibinvdp"
path="res://.godot/imported/Khanat - 3 - Au Coeur Du Reve.ogg-23b765856d874546d111705ac24462a9.oggvorbisstr"
[deps]
source_file="res://music/Les Chemins du Khanat/Khanat - 3 - Au Coeur Du Reve.ogg"
dest_files=["res://.godot/imported/Khanat - 3 - Au Coeur Du Reve.ogg-23b765856d874546d111705ac24462a9.oggvorbisstr"]
[params]
loop=true
loop_offset=0

View file

@ -0,0 +1,16 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOGGVorbis"
uid="uid://yx3krl15jhue"
path="res://.godot/imported/Khanat - 4 - Le Dispensaire.ogg-2e1c50cb48c932b00e70ef46d2a27d7b.oggvorbisstr"
[deps]
source_file="res://music/Les Chemins du Khanat/Khanat - 4 - Le Dispensaire.ogg"
dest_files=["res://.godot/imported/Khanat - 4 - Le Dispensaire.ogg-2e1c50cb48c932b00e70ef46d2a27d7b.oggvorbisstr"]
[params]
loop=true
loop_offset=0

View file

@ -0,0 +1,16 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOGGVorbis"
uid="uid://buc8jluocft7b"
path="res://.godot/imported/Khanat - 5 - Le Groska Et Les Scouis.ogg-9bb4a7e462f3d40f7cb235e0ed68ada7.oggvorbisstr"
[deps]
source_file="res://music/Les Chemins du Khanat/Khanat - 5 - Le Groska Et Les Scouis.ogg"
dest_files=["res://.godot/imported/Khanat - 5 - Le Groska Et Les Scouis.ogg-9bb4a7e462f3d40f7cb235e0ed68ada7.oggvorbisstr"]
[params]
loop=true
loop_offset=0

View file

@ -0,0 +1,16 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOGGVorbis"
uid="uid://bicua2almxnf2"
path="res://.godot/imported/Khanat - 6 - Combat Theme 1.ogg-8376a82bb7edfb76a657b8cbe4e3ba6a.oggvorbisstr"
[deps]
source_file="res://music/Les Chemins du Khanat/Khanat - 6 - Combat Theme 1.ogg"
dest_files=["res://.godot/imported/Khanat - 6 - Combat Theme 1.ogg-8376a82bb7edfb76a657b8cbe4e3ba6a.oggvorbisstr"]
[params]
loop=true
loop_offset=0

Binary file not shown.

View file

@ -0,0 +1,16 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOGGVorbis"
uid="uid://mhukl83ysrdc"
path="res://.godot/imported/Khanat - 7 - Natca.ogg-f6315f8fb631e596531c414e16285853.oggvorbisstr"
[deps]
source_file="res://music/Les Chemins du Khanat/Khanat - 7 - Natca.ogg"
dest_files=["res://.godot/imported/Khanat - 7 - Natca.ogg-f6315f8fb631e596531c414e16285853.oggvorbisstr"]
[params]
loop=true
loop_offset=0

View file

@ -0,0 +1,16 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOGGVorbis"
uid="uid://ce0usr5m2w7ev"
path="res://.godot/imported/Khanat - 8 - Le Concours De Tartes Aux Klums.ogg-3f58c68eac05ea5791814188aac24dbb.oggvorbisstr"
[deps]
source_file="res://music/Les Chemins du Khanat/Khanat - 8 - Le Concours De Tartes Aux Klums.ogg"
dest_files=["res://.godot/imported/Khanat - 8 - Le Concours De Tartes Aux Klums.ogg-3f58c68eac05ea5791814188aac24dbb.oggvorbisstr"]
[params]
loop=true
loop_offset=0

Binary file not shown.

View file

@ -0,0 +1,16 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOGGVorbis"
uid="uid://c7wtgnf7pkkqc"
path="res://.godot/imported/Khanat - 9 - Hoslet.ogg-43a64082d7615ab051c83693f314c2cd.oggvorbisstr"
[deps]
source_file="res://music/Les Chemins du Khanat/Khanat - 9 - Hoslet.ogg"
dest_files=["res://.godot/imported/Khanat - 9 - Hoslet.ogg-43a64082d7615ab051c83693f314c2cd.oggvorbisstr"]
[params]
loop=true
loop_offset=0

View file

@ -3,7 +3,7 @@ extends Control
@onready var music_player:AudioStreamPlayer = $Music @onready var music_player:AudioStreamPlayer = $Music
var official_music:Dictionary = {} var official_music:Dictionary = {}
var default_domain:String = "default" var default_domain:String = "Les Chemins du Khanat"
var current_domain:String = "" var current_domain:String = ""
var current_music:int = 0 var current_music:int = 0
var music_play:bool = false var music_play:bool = false
@ -11,7 +11,7 @@ var select_rand:bool = true
var list_music:Array = [] var list_music:Array = []
func _ready(): func _ready() -> void:
var directory:Directory = Directory.new() var directory:Directory = Directory.new()
var files = [] var files = []
get_tree().paused = false get_tree().paused = false
@ -37,12 +37,20 @@ func _ready():
_on_random_pressed() _on_random_pressed()
select_domain( default_domain ) select_domain( default_domain )
current_music = official_music[current_domain].size() current_music = official_music[current_domain].size()
# Get Mute state
Common.msg_debug("mute:" + str(user_settings.get_sound_mute()))
AudioServer.set_bus_mute(AudioServer.get_bus_index($Music.get_bus()), user_settings.get_sound_mute())
$Window/VBox/HBoxContainer/Mute.set_pressed(user_settings.get_sound_mute())
$Window/VBox/Tab/Music/HBox/Play.set_pressed(user_settings.get_sound_music_play())
$Window/VBox/Tab/Music/HBox/Random.set_pressed(user_settings.get_sound_music_random())
# Get Volume # Get Volume
# Common.msg_debug("volume :" + str($Music.get_volume_db())) # Common.msg_debug("volume :" + str($Music.get_volume_db()))
# var t = linear2db(0.0) # var t = linear2db(0.0)
# var u = db2linear($Music.get_volume_db()) # var u = db2linear($Music.get_volume_db())
# Common.msg_debug("volume :" + str(u)) # Common.msg_debug("volume :" + str(u))
var music_volume = float(user_settings.configuration["sound"]["music_volume"]) var music_volume = user_settings.get_sound_music_volume()
$Music.set_volume_db(linear2db(music_volume/100.0)) $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/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))) $Window/VBox/Tab/Mixer/MusicLevel/Value.set_text(str(int(db2linear($Music.get_volume_db()) * 100)))
@ -52,12 +60,15 @@ func _ready():
Common.msg_debug("bus_id: " + str(bus_id)) Common.msg_debug("bus_id: " + str(bus_id))
var glb_volume = AudioServer.get_bus_volume_db(bus_id) var glb_volume = AudioServer.get_bus_volume_db(bus_id)
Common.msg_debug("GLB Volume: " + str(glb_volume)) Common.msg_debug("GLB Volume: " + str(glb_volume))
var global_volume = user_settings.get_sound_global_volume()
AudioServer.set_bus_volume_db(AudioServer.get_bus_index($Music.get_bus()), linear2db(global_volume/100.0))
# AudioServer.get_bus_volume_db(AudioServer.get_bus_index($Music.get_bus())) # AudioServer.get_bus_volume_db(AudioServer.get_bus_index($Music.get_bus()))
$Window/VBox/Tab/Mixer/GlobalLevel/global.set_value( int(db2linear(AudioServer.get_bus_volume_db(AudioServer.get_bus_index($Music.get_bus()))) * 100.0)) $Window/VBox/Tab/Mixer/GlobalLevel/global.set_value( int(db2linear(AudioServer.get_bus_volume_db(AudioServer.get_bus_index($Music.get_bus()))) * 100.0))
$Window/VBox/Tab/Mixer/GlobalLevel/Value.set_text(str(int(db2linear(AudioServer.get_bus_volume_db(AudioServer.get_bus_index($Music.get_bus()))) * 100.0))) $Window/VBox/Tab/Mixer/GlobalLevel/Value.set_text(str(int(db2linear(AudioServer.get_bus_volume_db(AudioServer.get_bus_index($Music.get_bus()))) * 100.0)))
func select_domain(new_domain:String): func select_domain(new_domain:String) -> void:
var found:bool = false var found:bool = false
for key in official_music.keys(): for key in official_music.keys():
if new_domain == key: if new_domain == key:
@ -68,7 +79,7 @@ func select_domain(new_domain:String):
reinitialize_jukebox() reinitialize_jukebox()
func reinitialize_jukebox(): func reinitialize_jukebox() -> void:
list_music.clear() list_music.clear()
if select_rand: if select_rand:
var temp:Array var temp:Array
@ -83,7 +94,7 @@ func reinitialize_jukebox():
list_music.append(i) list_music.append(i)
func next_music(): func next_music() -> void:
var pos:float var pos:float
current_music += 1 current_music += 1
if current_music >= list_music.size(): if current_music >= list_music.size():
@ -125,13 +136,13 @@ func load_music(filepath: String):
return load_external_music(filepath) return load_external_music(filepath)
func _on_stream_finished(): func _on_stream_finished() -> void:
Common.msg_debug("_on_stream_finished") Common.msg_debug("_on_stream_finished")
music_player.stop() music_player.stop()
music_play = false music_play = false
func show_list_music(): func show_list_music() -> void:
for child in $Window/VBox/Tab/Music/ScrollContainer/ListMusic.get_children(): for child in $Window/VBox/Tab/Music/ScrollContainer/ListMusic.get_children():
child.queue_free() child.queue_free()
for pos in range(0, list_music.size()): for pos in range(0, list_music.size()):
@ -142,12 +153,12 @@ func show_list_music():
$Window/VBox/Tab/Music/ScrollContainer/ListMusic.add_child( music_box ) $Window/VBox/Tab/Music/ScrollContainer/ListMusic.add_child( music_box )
func force_music(pos:int): func force_music(pos:int) -> void:
Common.msg_debug("Force: " + str(pos)) Common.msg_debug("Force: " + str(pos))
play_music(pos) play_music(pos)
func play_music(pos: int): func play_music(pos: int) -> void:
if pos >= list_music.size(): if pos >= list_music.size():
return return
var filename:String = official_music[current_domain][list_music[pos]] var filename:String = official_music[current_domain][list_music[pos]]
@ -162,74 +173,78 @@ func play_music(pos: int):
show_list_music() show_list_music()
func _process(delta): func _process(delta) -> void:
if ! music_play and $Window/VBox/Tab/Music/HBox/Play.is_pressed(): if ! music_play and $Window/VBox/Tab/Music/HBox/Play.is_pressed():
next_music() next_music()
func _on_music_finished(): func _on_music_finished() -> void:
Common.msg_debug("_on_music_finished") Common.msg_debug("_on_music_finished")
music_player.stop() music_player.stop()
music_play = false music_play = false
func _on_end_music_timeout(): func _on_end_music_timeout() -> void:
# Timer end - sometimes, signal finished is not sent # Timer end - sometimes, signal finished is not sent
Common.msg_debug("_on_end_music_timeout") Common.msg_debug("_on_end_music_timeout")
music_play = false music_play = false
func show_config(): func show_config() -> void:
#$Window.popup_centered() #$Window.popup_centered()
$Window.visible = true $Window.visible = true
func _on_button_pressed(): func _on_button_pressed() -> void:
$Window.hide() $Window.hide()
func _on_play_pressed(): func _on_play_pressed() -> void:
var current_time = $EndMusic.get_time_left() var current_time = $EndMusic.get_time_left()
Common.msg_debug("_on_play_pressed : " + str(current_time)) Common.msg_debug("_on_play_pressed : " + str(current_time))
if $Window/VBox/Tab/Music/HBox/Play.is_pressed(): if $Window/VBox/Tab/Music/HBox/Play.is_pressed():
$Music.set_stream_paused(false) $Music.set_stream_paused(false)
$EndMusic.set_paused(false) $EndMusic.set_paused(false)
user_settings.set_sound_music_play(true)
else: else:
$Music.set_stream_paused(true) $Music.set_stream_paused(true)
$EndMusic.set_paused(true) $EndMusic.set_paused(true)
user_settings.set_sound_music_play(false)
func _on_random_pressed() -> void:
func _on_random_pressed():
if $Window/VBox/Tab/Music/HBox/Random.is_pressed(): if $Window/VBox/Tab/Music/HBox/Random.is_pressed():
select_rand = true select_rand = true
user_settings.set_sound_music_random(true)
else: else:
select_rand = false select_rand = false
user_settings.set_sound_music_random(false)
func _on_reinit_pressed(): func _on_reinit_pressed() -> void:
reinitialize_jukebox() reinitialize_jukebox()
play_music(0) play_music(0)
func _on_mute_toggled(button_pressed): func _on_mute_toggled(button_pressed) -> void:
AudioServer.set_bus_mute(AudioServer.get_bus_index($Music.get_bus()), button_pressed) AudioServer.set_bus_mute(AudioServer.get_bus_index($Music.get_bus()), button_pressed)
user_settings.set_sound_mute(button_pressed)
func _on_effect_value_changed(value): func _on_effect_value_changed(value) -> void:
$Window/VBox/Tab/Mixer/EffectLevel/Value.set_text(str(value)) $Window/VBox/Tab/Mixer/EffectLevel/Value.set_text(str(value))
func _on_music_value_changed(value): func _on_music_value_changed(value) -> void:
$Music.set_volume_db(linear2db(value/100.0)) $Music.set_volume_db(linear2db(value/100.0))
$Window/VBox/Tab/Mixer/MusicLevel/Value.set_text(str(value)) $Window/VBox/Tab/Mixer/MusicLevel/Value.set_text(str(value))
user_settings.configuration["sound"]["music_volume"] = value user_settings.set_sound_music_volume(value)
user_settings.save()
func _on_global_value_changed(value): func _on_global_value_changed(value) -> void:
AudioServer.set_bus_volume_db(AudioServer.get_bus_index($Music.get_bus()), linear2db(value/100.0)) AudioServer.set_bus_volume_db(AudioServer.get_bus_index($Music.get_bus()), linear2db(value/100.0))
$Window/VBox/Tab/Mixer/GlobalLevel/Value.set_text(str(value)) $Window/VBox/Tab/Mixer/GlobalLevel/Value.set_text(str(value))
user_settings.set_sound_global_volume(value)
func _on_window_close_requested(): func _on_window_close_requested() -> void:
$Window.hide() $Window.hide()

View file

@ -1,25 +1,116 @@
extends Node extends Node
var cfg_path = "user://settings.cfg" var cfg_path = "user://settings.cfg"
var updated = false
@onready var configuration = get_settings() @onready var configuration = get_settings()
func save(): func save():
if not updated:
return
Common.msg_debug("Save to config file : %s/%s" % [OS.get_user_data_dir(), cfg_path.replace("user://", "")]) Common.msg_debug("Save to config file : %s/%s" % [OS.get_user_data_dir(), cfg_path.replace("user://", "")])
Common.msg_debug(str(configuration))
var file = ConfigFile.new() var file = ConfigFile.new()
for section in configuration.keys(): for section in configuration.keys():
for key in configuration[section].keys(): for key in configuration[section].keys():
file.set_value(section, key, configuration[section][key]) file.set_value(section, key, configuration[section][key])
file.save(cfg_path) file.save(cfg_path)
Common.msg_debug("Saved to config file : %s/%s" % [OS.get_user_data_dir(), cfg_path.replace("user://", "")])
func get_settings():
func get_settings() -> Dictionary:
var cfg = {} var cfg = {}
var config = ConfigFile.new() var config = ConfigFile.new()
var cfg_file_content = config.load(cfg_path) var cfg_file_content = config.load(cfg_path)
if cfg_file_content != OK: if cfg_file_content != OK:
return cfg return cfg
for section in config.get_sections(): for section in config.get_sections():
print ("Config section : %s" % section) Common.msg_debug ("Config section : %s" % section)
for parameter in config.get_section_keys(section): for parameter in config.get_section_keys(section):
print("Config parameter : %s" % parameter) Common.msg_debug("Config parameter : %s" % parameter)
cfg[section] = {parameter:config.get_value(section, parameter)} if not cfg.has(section):
cfg[section] = {}
cfg[section][parameter] = config.get_value(section, parameter)
Common.msg_debug("After load config: " + str(cfg))
return cfg return cfg
func set_float_group_key(group:String, key:String, value:float):
Common.msg_debug("Set config[" + group + "][" + key + "] = " + str(value))
if not configuration.has(group):
configuration[group] = {}
if configuration[group].has(key):
if configuration[group][key] == value:
return
updated = true
configuration[group][key] = value
func get_float_group_key(group:String, key:String, default:float) -> float:
if configuration.has(group):
if configuration[group].has(key):
if typeof(configuration[group][key]) == TYPE_FLOAT:
return configuration[group][key]
Common.msg_debug("type:" + str(typeof(configuration[group][key])))
set_float_group_key(group, key, default)
return default
func set_bool_group_key(group:String, key:String, value:bool):
Common.msg_debug("Set config[" + group + "][" + key + "] = " + str(value))
if not configuration.has(group):
configuration[group] = {}
if configuration[group].has(key):
if configuration[group][key] == value:
return
updated = true
configuration[group][key] = value
func get_bool_group_key(group:String, key:String, default:bool) -> bool:
if configuration.has(group):
if configuration[group].has(key):
if typeof(configuration[group][key]) == TYPE_BOOL:
return configuration[group][key]
Common.msg_debug("type:" + str(typeof(configuration[group][key])))
set_bool_group_key(group, key, default)
return default
func set_sound_music_volume(value: float):
return set_float_group_key("sound", "music_volume", value)
func get_sound_music_volume() -> float:
return get_float_group_key("sound", "music_volume", 100.0)
func set_sound_global_volume(value: float):
return set_float_group_key("sound", "global_volume", value)
func get_sound_global_volume() -> float:
return get_float_group_key("sound", "global_volume", 100.0)
func set_sound_mute(value: bool):
return set_bool_group_key("sound", "mute", value)
func get_sound_mute() -> bool:
return get_bool_group_key("sound", "mute", false)
func set_sound_music_play(value: bool):
return set_bool_group_key("sound", "music_play", value)
func get_sound_music_play() -> bool:
return get_bool_group_key("sound", "music_play", true)
func set_sound_music_random(value: bool):
return set_bool_group_key("sound", "music_random", value)
func get_sound_music_random() -> bool:
return get_bool_group_key("sound", "music_random", true)