Add settings menu options

soundtrack
Ensar Sarajčić 2021-11-17 23:23:12 +01:00
parent 9075965e61
commit 3ac3ea268c
11 changed files with 289 additions and 3 deletions

View File

@ -0,0 +1,15 @@
[gd_resource type="AudioBusLayout" format=2]
[resource]
bus/1/name = "Sound"
bus/1/solo = false
bus/1/mute = false
bus/1/bypass_fx = false
bus/1/volume_db = 0.0
bus/1/send = "Master"
bus/2/name = "Music"
bus/2/solo = false
bus/2/mute = false
bus/2/bypass_fx = false
bus/2/volume_db = 0.0
bus/2/send = "Master"

View File

@ -31,6 +31,10 @@ run/main_scene="res://scenes/menu/main_menu.tscn"
boot_splash/image="res://assets/bugged-racing-cover.png" boot_splash/image="res://assets/bugged-racing-cover.png"
config/icon="res://icon.png" config/icon="res://icon.png"
[autoload]
GlobalSettings="*res://settings/GlobalSettings.gd"
[gui] [gui]
theme/use_hidpi=true theme/use_hidpi=true

View File

@ -0,0 +1,49 @@
extends Panel
onready var master_bus := AudioServer.get_bus_index("Master")
onready var sound_bus := AudioServer.get_bus_index("Sound")
onready var music_bus := AudioServer.get_bus_index("Music")
onready var master_slider: HSlider = $MarginContainer/VSplitContainer/CenterContainer/VBoxContainer/MasterSlider
onready var sound_slider: HSlider = $MarginContainer/VSplitContainer/CenterContainer/VBoxContainer/SoundEffectsSlider
onready var music_slider: HSlider = $MarginContainer/VSplitContainer/CenterContainer/VBoxContainer/MusicSlider
onready var auto_clutch_cb: CheckBox = $MarginContainer/VSplitContainer/CenterContainer/VBoxContainer/AutoClutchCheckBox
onready var automatic_transmission_cb: CheckBox = $MarginContainer/VSplitContainer/CenterContainer/VBoxContainer/AutomaticTransmissionCheckBox
onready var debug_cb: CheckBox = $MarginContainer/VSplitContainer/CenterContainer/VBoxContainer/DebugModeCheckBox
func _ready() -> void:
master_slider.value = db2linear(AudioServer.get_bus_volume_db(master_bus))
sound_slider.value = db2linear(AudioServer.get_bus_volume_db(sound_bus))
music_slider.value = db2linear(AudioServer.get_bus_volume_db(music_bus))
debug_cb.pressed = GlobalSettings.debug
auto_clutch_cb.pressed = GlobalSettings.auto_clutch
automatic_transmission_cb.pressed = GlobalSettings.automatic_transmission
func _on_debug_toggled(new_state: bool) -> void:
GlobalSettings.debug = new_state
func _on_autoclutch_toggled(new_state: bool) -> void:
GlobalSettings.auto_clutch = new_state
func _on_automatictransmission_toggled(new_state: bool) -> void:
GlobalSettings.automatic_transmission = new_state
auto_clutch_cb.disabled = new_state == true
func _on_BackButton_pressed() -> void:
get_tree().change_scene("res://scenes/menu/main_menu.tscn")
func _on_MasterSlider_value_changed(new_value: float) -> void:
AudioServer.set_bus_volume_db(master_bus, linear2db(new_value))
func _on_SoundEffectsSlider_value_changed(new_value: float) -> void:
AudioServer.set_bus_volume_db(sound_bus, linear2db(new_value))
func _on_MusicSlider_value_changed(new_value: float) -> void:
AudioServer.set_bus_volume_db(music_bus, linear2db(new_value))

View File

@ -0,0 +1,210 @@
[gd_scene load_steps=7 format=2]
[ext_resource path="res://assets/fonts/kenney-future-narrow.ttf" type="DynamicFontData" id=1]
[ext_resource path="res://scenes/menu/settings_menu.gd" type="Script" id=2]
[sub_resource type="DynamicFont" id=1]
size = 64
font_data = ExtResource( 1 )
[sub_resource type="DynamicFont" id=4]
size = 24
font_data = ExtResource( 1 )
[sub_resource type="DynamicFont" id=3]
font_data = ExtResource( 1 )
[sub_resource type="DynamicFont" id=5]
font_data = ExtResource( 1 )
[node name="SettingsMenu" type="Panel"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 2 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MarginContainer" type="MarginContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 20.0
margin_top = 20.0
margin_right = -20.0
margin_bottom = -20.0
[node name="VSplitContainer" type="VSplitContainer" parent="MarginContainer"]
margin_right = 984.0
margin_bottom = 602.0
dragger_visibility = 1
[node name="HSplitContainer" type="HSplitContainer" parent="MarginContainer/VSplitContainer"]
margin_right = 984.0
margin_bottom = 72.0
dragger_visibility = 1
[node name="BackButton" type="Button" parent="MarginContainer/VSplitContainer/HSplitContainer"]
margin_right = 75.0
margin_bottom = 72.0
text = "Back"
[node name="Title" type="Label" parent="MarginContainer/VSplitContainer/HSplitContainer"]
margin_left = 99.0
margin_right = 984.0
margin_bottom = 72.0
custom_fonts/font = SubResource( 1 )
text = "Settings"
align = 1
valign = 1
[node name="CenterContainer" type="CenterContainer" parent="MarginContainer/VSplitContainer"]
margin_top = 96.0
margin_right = 984.0
margin_bottom = 602.0
[node name="VBoxContainer" type="VBoxContainer" parent="MarginContainer/VSplitContainer/CenterContainer"]
margin_left = 311.0
margin_right = 672.0
margin_bottom = 506.0
[node name="Gameplay" type="Label" parent="MarginContainer/VSplitContainer/CenterContainer/VBoxContainer"]
margin_right = 361.0
margin_bottom = 27.0
custom_fonts/font = SubResource( 4 )
text = "Gameplay"
align = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="AutoClutchCheckBox" type="CheckBox" parent="MarginContainer/VSplitContainer/CenterContainer/VBoxContainer"]
margin_top = 35.0
margin_right = 361.0
margin_bottom = 83.0
custom_fonts/font = SubResource( 3 )
text = "Automatic Clutch"
align = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="AutomaticTransmissionCheckBox" type="CheckBox" parent="MarginContainer/VSplitContainer/CenterContainer/VBoxContainer"]
margin_top = 91.0
margin_right = 361.0
margin_bottom = 139.0
custom_fonts/font = SubResource( 3 )
text = "Automatic Transmission"
align = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="AudioLabel" type="Label" parent="MarginContainer/VSplitContainer/CenterContainer/VBoxContainer"]
margin_top = 147.0
margin_right = 361.0
margin_bottom = 174.0
custom_fonts/font = SubResource( 4 )
text = "Audio"
align = 1
[node name="MasterLabel" type="Label" parent="MarginContainer/VSplitContainer/CenterContainer/VBoxContainer"]
margin_top = 182.0
margin_right = 361.0
margin_bottom = 200.0
custom_fonts/font = SubResource( 5 )
text = "Master"
align = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MasterSlider" type="HSlider" parent="MarginContainer/VSplitContainer/CenterContainer/VBoxContainer"]
margin_top = 208.0
margin_right = 361.0
margin_bottom = 240.0
max_value = 1.0
step = 0.05
value = 1.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="SoundEffectsLabel" type="Label" parent="MarginContainer/VSplitContainer/CenterContainer/VBoxContainer"]
margin_top = 248.0
margin_right = 361.0
margin_bottom = 266.0
custom_fonts/font = SubResource( 5 )
text = "Sound Effects"
align = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="SoundEffectsSlider" type="HSlider" parent="MarginContainer/VSplitContainer/CenterContainer/VBoxContainer"]
margin_top = 274.0
margin_right = 361.0
margin_bottom = 306.0
max_value = 1.0
step = 0.05
value = 1.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MusicLabel" type="Label" parent="MarginContainer/VSplitContainer/CenterContainer/VBoxContainer"]
margin_top = 314.0
margin_right = 361.0
margin_bottom = 332.0
custom_fonts/font = SubResource( 5 )
text = "Music"
align = 1
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MusicSlider" type="HSlider" parent="MarginContainer/VSplitContainer/CenterContainer/VBoxContainer"]
margin_top = 340.0
margin_right = 361.0
margin_bottom = 372.0
max_value = 1.0
step = 0.05
value = 1.0
__meta__ = {
"_edit_use_anchors_": false
}
[node name="VideoLabel" type="Label" parent="MarginContainer/VSplitContainer/CenterContainer/VBoxContainer"]
margin_top = 380.0
margin_right = 361.0
margin_bottom = 407.0
custom_fonts/font = SubResource( 4 )
text = "Video"
align = 1
[node name="DebugLabel" type="Label" parent="MarginContainer/VSplitContainer/CenterContainer/VBoxContainer"]
margin_top = 415.0
margin_right = 361.0
margin_bottom = 442.0
custom_fonts/font = SubResource( 4 )
text = "Debug"
align = 1
[node name="DebugModeCheckBox" type="CheckBox" parent="MarginContainer/VSplitContainer/CenterContainer/VBoxContainer"]
margin_top = 450.0
margin_right = 361.0
margin_bottom = 498.0
custom_fonts/font = SubResource( 3 )
text = "Debug mode (visible checkpoints)"
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer/VSplitContainer/CenterContainer/VBoxContainer"]
margin_top = 506.0
margin_right = 361.0
margin_bottom = 506.0
[connection signal="pressed" from="MarginContainer/VSplitContainer/HSplitContainer/BackButton" to="." method="_on_BackButton_pressed"]
[connection signal="toggled" from="MarginContainer/VSplitContainer/CenterContainer/VBoxContainer/AutoClutchCheckBox" to="." method="_on_autoclutch_toggled"]
[connection signal="toggled" from="MarginContainer/VSplitContainer/CenterContainer/VBoxContainer/AutomaticTransmissionCheckBox" to="." method="_on_automatictransmission_toggled"]
[connection signal="value_changed" from="MarginContainer/VSplitContainer/CenterContainer/VBoxContainer/MasterSlider" to="." method="_on_MasterSlider_value_changed"]
[connection signal="value_changed" from="MarginContainer/VSplitContainer/CenterContainer/VBoxContainer/SoundEffectsSlider" to="." method="_on_SoundEffectsSlider_value_changed"]
[connection signal="value_changed" from="MarginContainer/VSplitContainer/CenterContainer/VBoxContainer/MusicSlider" to="." method="_on_MusicSlider_value_changed"]
[connection signal="toggled" from="MarginContainer/VSplitContainer/CenterContainer/VBoxContainer/DebugModeCheckBox" to="." method="_on_debug_toggled"]

View File

@ -72,7 +72,6 @@ shape = SubResource( 3 )
[node name="Track" type="Spatial" parent="."] [node name="Track" type="Spatial" parent="."]
script = ExtResource( 4 ) script = ExtResource( 4 )
track_path = NodePath("Path") track_path = NodePath("Path")
debug = true
debug_material = SubResource( 9 ) debug_material = SubResource( 9 )
[node name="Path" type="Path" parent="Track"] [node name="Path" type="Path" parent="Track"]

View File

@ -7,7 +7,6 @@ signal lap_complete(lap_time)
export (NodePath) var track_path = null export (NodePath) var track_path = null
export (int, 10, 50) var checkpoint_count = 20 export (int, 10, 50) var checkpoint_count = 20
export (Vector2) var checkpoint_dim = Vector2(20, 15) export (Vector2) var checkpoint_dim = Vector2(20, 15)
export (bool) var debug = false
export (Material) var debug_material = null export (Material) var debug_material = null
onready var checkpoints = $Checkpoints onready var checkpoints = $Checkpoints
@ -28,7 +27,7 @@ func _ready() -> void:
new_checkpoint.transform.origin = path.curve.interpolate_baked(section, true) new_checkpoint.transform.origin = path.curve.interpolate_baked(section, true)
section += section_size section += section_size
checkpoints.add_child(new_checkpoint) checkpoints.add_child(new_checkpoint)
if debug: if GlobalSettings.debug:
var mesh = CylinderMesh.new() var mesh = CylinderMesh.new()
mesh.top_radius = checkpoint_dim.y mesh.top_radius = checkpoint_dim.y
mesh.bottom_radius = checkpoint_dim.y mesh.bottom_radius = checkpoint_dim.y

View File

@ -0,0 +1,6 @@
extends Node
var debug: bool = false
var auto_clutch: bool = false
var automatic_transmission: bool = false

View File

@ -96,6 +96,7 @@ shape = SubResource( 1 )
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.14201, 0.968668 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.14201, 0.968668 )
stream = SubResource( 2 ) stream = SubResource( 2 )
unit_db = 14.0 unit_db = 14.0
bus = "Sound"
[node name="Smoke" type="Particles" parent="." index="8"] [node name="Smoke" type="Particles" parent="." index="8"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.31514, 0.383062, -1.51247 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.31514, 0.383062, -1.51247 )

View File

@ -98,6 +98,7 @@ transform = Transform( -1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.14201, 0.968668 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.14201, 0.968668 )
stream = SubResource( 3 ) stream = SubResource( 3 )
unit_db = 14.0 unit_db = 14.0
bus = "Sound"
[node name="Smoke" type="Particles" parent="." index="8"] [node name="Smoke" type="Particles" parent="." index="8"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.855953, -1.87797 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.855953, -1.87797 )

View File

@ -98,6 +98,7 @@ shape = SubResource( 11 )
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.791119, -2.27857 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.791119, -2.27857 )
stream = SubResource( 12 ) stream = SubResource( 12 )
unit_db = 14.0 unit_db = 14.0
bus = "Sound"
[node name="Smoke" type="Particles" parent="." index="8"] [node name="Smoke" type="Particles" parent="." index="8"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.686323, -2.72067 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.686323, -2.72067 )

View File

@ -42,4 +42,5 @@ script = ExtResource( 1 )
stream = SubResource( 6 ) stream = SubResource( 6 )
unit_db = 25.0 unit_db = 25.0
unit_size = 2.0 unit_size = 2.0
bus = "Sound"
area_mask = 2 area_mask = 2