Bläddra i källkod

Associe chaque slider a un bus

Associe le nom de chaque bus dans un script.

Permet de recuperer le volume associe du bus lors de sa creation.
DricomDragon 11 månader sedan
förälder
incheckning
6bc43afcbf

+ 14 - 0
godot/composants/interface/pause/bus_volume.gd

@@ -0,0 +1,14 @@
+extends Slider
+
+
+signal volume_change(String, float)
+
+@export var nom_bus: String = "Master"
+
+
+func _ready() -> void:
+	value_changed.connect(_met_a_jour_volume)
+
+
+func _met_a_jour_volume(nouveau_volume: float) -> void:
+	volume_change.emit(nom_bus, nouveau_volume)

+ 8 - 3
godot/composants/interface/pause/pause_menu.tscn

@@ -1,8 +1,9 @@
-[gd_scene load_steps=4 format=3 uid="uid://cvsfngjyx7xvw"]
+[gd_scene load_steps=5 format=3 uid="uid://cvsfngjyx7xvw"]
 
 [ext_resource type="Script" path="res://composants/interface/pause/pause_menu.gd" id="1_c51fd"]
 [ext_resource type="Texture2D" uid="uid://bkupreskydgkg" path="res://composants/interface/pause/sprite.png" id="2_2pxrh"]
 [ext_resource type="Script" path="res://composants/interface/pause/volume_control.gd" id="3_5at13"]
+[ext_resource type="Script" path="res://composants/interface/pause/bus_volume.gd" id="4_ygvs3"]
 
 [node name="PauseMenu" type="VSplitContainer"]
 process_mode = 3
@@ -53,15 +54,19 @@ layout_mode = 2
 size_flags_horizontal = 3
 min_value = -60.0
 max_value = 0.0
+script = ExtResource("4_ygvs3")
+nom_bus = "Musique"
 
 [node name="Bruits" type="HSlider" parent="VSplitContainer/VolumeControl"]
 layout_mode = 2
 size_flags_horizontal = 3
 min_value = -60.0
 max_value = 0.0
+script = ExtResource("4_ygvs3")
+nom_bus = "Bruits"
 
 [connection signal="pressed" from="VSplitContainer/Buttons/Reprendre" to="." method="_quand_bouton_reprendre_est_presse"]
 [connection signal="pressed" from="VSplitContainer/Buttons/RetourEcranTitre" to="." method="_quand_bouton_retour_titre_est_presse"]
 [connection signal="pressed" from="VSplitContainer/Buttons/QuitterLeJeu" to="." method="_quand_bouton_quitter_est_presse"]
-[connection signal="value_changed" from="VSplitContainer/VolumeControl/Musique" to="VSplitContainer/VolumeControl" method="_quand_volume_musique_change"]
-[connection signal="value_changed" from="VSplitContainer/VolumeControl/Bruits" to="VSplitContainer/VolumeControl" method="_quand_volume_bruits_change"]
+[connection signal="volume_change" from="VSplitContainer/VolumeControl/Musique" to="VSplitContainer/VolumeControl" method="_quand_volume_change"]
+[connection signal="volume_change" from="VSplitContainer/VolumeControl/Bruits" to="VSplitContainer/VolumeControl" method="_quand_volume_change"]

+ 2 - 6
godot/composants/interface/pause/volume_control.gd

@@ -1,12 +1,8 @@
 extends Control
 
 
-func _quand_volume_musique_change(nouveau_volume: float) -> void:
-	_ajuster_volume("Musique", nouveau_volume)
-
-
-func _quand_volume_bruits_change(nouveau_volume: float) -> void:
-	_ajuster_volume("Bruits", nouveau_volume)
+func _quand_volume_change(nom_bus: String, nouveau_volume: float) -> void:
+	_ajuster_volume(nom_bus, nouveau_volume)
 
 
 func _ajuster_volume(nom_bus: String, nouveau_volume: float) -> void:

+ 1 - 0
godot/exec/game.tscn

@@ -13,6 +13,7 @@
 [node name="PauseMenu" parent="." instance=ExtResource("2_petgp")]
 
 [node name="Musique" type="AudioStreamPlayer" parent="."]
+process_mode = 3
 stream = ExtResource("3_aigju")
 autoplay = true
 bus = &"Musique"