diff options
author | 2023-02-26 17:12:07 +0100 | |
---|---|---|
committer | 2023-02-26 17:12:07 +0100 | |
commit | 93c6b207c11fdaba484410eb53fc11b35fbbb3bd (patch) | |
tree | 911753c663adb3955ab15cc8b5ac37498c2fda6e /game/src/OptionMenu/VolumeGrid.gd | |
parent | a37c5085c3b7ee515789d681c8c18d71071fb771 (diff) |
Add Setting Sanatization (#21)
Diffstat (limited to 'game/src/OptionMenu/VolumeGrid.gd')
-rw-r--r-- | game/src/OptionMenu/VolumeGrid.gd | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/game/src/OptionMenu/VolumeGrid.gd b/game/src/OptionMenu/VolumeGrid.gd index fae5ff6..8d5a016 100644 --- a/game/src/OptionMenu/VolumeGrid.gd +++ b/game/src/OptionMenu/VolumeGrid.gd @@ -1,8 +1,8 @@ extends GridContainer -const RATIO_FOR_LINEAR = 100 +const RATIO_FOR_LINEAR : float = 100 -var _slider_dictionary := {} +var _slider_dictionary : Dictionary func get_db_as_volume_value(db : float) -> float: # db_to_linear produces a float between 0 and 1 from a db value @@ -12,7 +12,7 @@ func get_volume_value_as_db(value : float) -> float: # linear_to_db consumes a float between 0 and 1 to produce the db value return linear_to_db(value / RATIO_FOR_LINEAR) -func add_volume_column(bus_name : StringName, bus_index : int) -> HSlider: +func add_volume_row(bus_name : StringName, bus_index : int) -> HSlider: var volume_label := Label.new() volume_label.text = bus_name + " Volume" add_child(volume_label) @@ -33,22 +33,22 @@ func add_volume_column(bus_name : StringName, bus_index : int) -> HSlider: func _ready(): for bus_index in AudioServer.bus_count: - add_volume_column(AudioServer.get_bus_name(bus_index), bus_index) + add_volume_row(AudioServer.get_bus_name(bus_index), bus_index) func _on_slider_value_changed(value : float, bus_index : int) -> void: AudioServer.set_bus_volume_db(bus_index, get_volume_value_as_db(value)) func _on_options_menu_load_settings(load_file : ConfigFile): - for volume_label_text in _slider_dictionary: - _slider_dictionary[volume_label_text].load_setting(load_file) + for volume_slider in _slider_dictionary.values(): + volume_slider.load_setting(load_file) func _on_options_menu_save_settings(save_file : ConfigFile): - for volume_label_text in _slider_dictionary: - _slider_dictionary[volume_label_text].save_setting(save_file) + for volume_slider in _slider_dictionary.values(): + volume_slider.save_setting(save_file) func _on_options_menu_reset_settings(): - for volume_label_text in _slider_dictionary: - _slider_dictionary[volume_label_text].reset_setting() + for volume_slider in _slider_dictionary.values(): + volume_slider.reset_setting() |