Slider fine

This commit is contained in:
Albion
2022-12-11 10:33:26 +01:00
parent edb53171d0
commit 4e51cae845
3 changed files with 21 additions and 21 deletions

View File

@@ -1,10 +1,12 @@
extends Control
var master_bus
# Called when the node enters the scene tree for the first time.
# Called when the node enters the scene tree for the first time.
func _ready():
$VBoxContainer/Start.grab_focus() # Replace with function body.
master_bus = AudioServer.get_bus_index("Master")
# Called every frame. 'delta' is the elapsed time since the previous frame.
@@ -33,3 +35,12 @@ func _on_full_screen_pressed():
if DisplayServer.window_get_mode() != DisplayServer.WINDOW_MODE_WINDOWED:
DisplayServer.window_set_mode(DisplayServer.WINDOW_MODE_WINDOWED)
func _on_vol_slider_value_changed(value):
AudioServer.set_bus_volume_db(master_bus, value)
if value == -30:
AudioServer.set_bus_mute(master_bus,true)
else:
AudioServer.set_bus_mute(master_bus, false)

0
menu/VolSlider.gd Normal file
View File

View File

@@ -1,7 +1,6 @@
[gd_scene load_steps=4 format=3 uid="uid://bsmsdlf5jiukx"]
[gd_scene load_steps=3 format=3 uid="uid://bsmsdlf5jiukx"]
[ext_resource type="Script" path="res://menu/MainMenu.gd" id="1_hyw8p"]
[ext_resource type="Script" path="res://menu/VolSlider.gd" id="2_h85ei"]
[ext_resource type="AudioStream" uid="uid://bmawra1dgi812" path="res://Assets/Sounds/_MUSIC_/MenuGameJamLoop.wav" id="3_ktf88"]
[node name="MainMenu" type="Control"]
@@ -14,6 +13,7 @@ grow_vertical = 2
script = ExtResource("1_hyw8p")
[node name="ColorRect" type="ColorRect" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
@@ -22,6 +22,7 @@ grow_vertical = 2
color = Color(0.513726, 0.403922, 0.27451, 1)
[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
@@ -35,42 +36,30 @@ grow_horizontal = 2
grow_vertical = 2
[node name="Start" type="Button" parent="VBoxContainer"]
offset_right = 87.0
offset_bottom = 31.0
layout_mode = 2
text = "Start
"
[node name="Tutorial" type="Button" parent="VBoxContainer"]
offset_top = 35.0
offset_right = 87.0
offset_bottom = 66.0
layout_mode = 2
text = "Tutorial
"
[node name="Settings" type="Button" parent="VBoxContainer"]
offset_top = 70.0
offset_right = 87.0
offset_bottom = 101.0
layout_mode = 2
text = "Volume:"
[node name="VolSlider" type="HSlider" parent="VBoxContainer"]
offset_top = 105.0
offset_right = 87.0
offset_bottom = 121.0
layout_mode = 2
min_value = -30.0
max_value = 0.0
script = ExtResource("2_h85ei")
[node name="Quit" type="Button" parent="VBoxContainer"]
offset_top = 125.0
offset_right = 87.0
offset_bottom = 156.0
layout_mode = 2
text = "Quit"
[node name="FullScreen" type="Button" parent="VBoxContainer"]
offset_top = 160.0
offset_right = 87.0
offset_bottom = 191.0
layout_mode = 2
text = "Fullscreen"
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
@@ -80,6 +69,6 @@ autoplay = true
[connection signal="pressed" from="VBoxContainer/Start" to="." method="_on_start_pressed"]
[connection signal="pressed" from="VBoxContainer/Tutorial" to="." method="_on_tutorial_pressed"]
[connection signal="pressed" from="VBoxContainer/Settings" to="." method="_on_settings_pressed"]
[connection signal="value_changed" from="VBoxContainer/VolSlider" to="VBoxContainer/VolSlider" method="_on_value_changed"]
[connection signal="value_changed" from="VBoxContainer/VolSlider" to="." method="_on_vol_slider_value_changed"]
[connection signal="pressed" from="VBoxContainer/Quit" to="." method="_on_quit_pressed"]
[connection signal="pressed" from="VBoxContainer/FullScreen" to="." method="_on_full_screen_pressed"]