Add music in main menu
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,24 @@
|
||||
[remap]
|
||||
|
||||
importer="wav"
|
||||
type="AudioStreamWAV"
|
||||
uid="uid://dcpehnwdueyyo"
|
||||
path="res://.godot/imported/Space Horror InGame Music (Exploration) _Clement Panchout.wav-9d35410fa91625c5f4d02f369a39bf2e.sample"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://audio/Space Horror InGame Music (Exploration) _Clement Panchout.wav"
|
||||
dest_files=["res://.godot/imported/Space Horror InGame Music (Exploration) _Clement Panchout.wav-9d35410fa91625c5f4d02f369a39bf2e.sample"]
|
||||
|
||||
[params]
|
||||
|
||||
force/8_bit=false
|
||||
force/mono=false
|
||||
force/max_rate=false
|
||||
force/max_rate_hz=44100
|
||||
edit/trim=false
|
||||
edit/normalize=false
|
||||
edit/loop_mode=2
|
||||
edit/loop_begin=0
|
||||
edit/loop_end=-1
|
||||
compress/mode=2
|
||||
2
audio/sources.yaml
Normal file
2
audio/sources.yaml
Normal file
@@ -0,0 +1,2 @@
|
||||
- fileName: Space Horror InGame Music (Exploration) _Clement Panchout
|
||||
commonUrl: https://clement-panchout.itch.io/yet-another-free-music-pack
|
||||
15
default_bus_layout.tres
Normal file
15
default_bus_layout.tres
Normal file
@@ -0,0 +1,15 @@
|
||||
[gd_resource type="AudioBusLayout" format=3 uid="uid://c4bwiq14nq074"]
|
||||
|
||||
[resource]
|
||||
bus/1/name = &"SFX"
|
||||
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"
|
||||
@@ -1,4 +1,30 @@
|
||||
extends Node
|
||||
|
||||
const MUSIC_PATH := "res://audio/Space Horror InGame Music (Exploration) _Clement Panchout.wav"
|
||||
|
||||
@onready var music_player := AudioStreamPlayer.new()
|
||||
var is_music_playing := false
|
||||
|
||||
func _ready():
|
||||
pass
|
||||
if is_music_playing:
|
||||
return
|
||||
|
||||
var stream: AudioStream = load(MUSIC_PATH)
|
||||
if not stream:
|
||||
push_error("Failed to load music stream: %s" % MUSIC_PATH)
|
||||
return
|
||||
|
||||
# Loop safely
|
||||
if stream is AudioStreamWAV:
|
||||
stream.loop_mode = AudioStreamWAV.LOOP_FORWARD
|
||||
elif stream is AudioStreamOggVorbis:
|
||||
stream.loop = true
|
||||
|
||||
# Setup player
|
||||
music_player.stream = stream
|
||||
music_player.bus = "Music"
|
||||
music_player.volume_db = linear_to_db(SettingsManager.get_setting("music_volume"))
|
||||
add_child(music_player)
|
||||
music_player.play()
|
||||
|
||||
is_music_playing = true
|
||||
|
||||
@@ -31,7 +31,10 @@ func load_settings():
|
||||
print("No settings file found, using defaults")
|
||||
print("Language is set to: ", settings["language"])
|
||||
TranslationServer.set_locale(settings["language"])
|
||||
# TODO: Apply values for volume control
|
||||
AudioServer.set_bus_volume_db(AudioServer.get_bus_index("Master"), linear_to_db(settings["master_volume"]))
|
||||
AudioServer.set_bus_volume_db(AudioServer.get_bus_index("Music"), linear_to_db(settings["music_volume"]))
|
||||
AudioServer.set_bus_volume_db(AudioServer.get_bus_index("SFX"), linear_to_db(settings["sfx_volume"]))
|
||||
|
||||
|
||||
func save_settings():
|
||||
var config = ConfigFile.new()
|
||||
|
||||
@@ -30,9 +30,19 @@ func _ready():
|
||||
update_text()
|
||||
|
||||
func _on_volume_slider_changed(value, setting_key):
|
||||
var pretty_name = setting_key.capitalize().replace("_", " ")
|
||||
settings_manager.set_setting(setting_key, value)
|
||||
print("%s changed to: %f" % [pretty_name, value])
|
||||
|
||||
var bus_map = {
|
||||
"master_volume": "Master",
|
||||
"music_volume": "Music",
|
||||
"sfx_volume": "SFX"
|
||||
}
|
||||
|
||||
if bus_map.has(setting_key):
|
||||
var bus_index = AudioServer.get_bus_index(bus_map[setting_key])
|
||||
if bus_index >= 0:
|
||||
AudioServer.set_bus_volume_db(bus_index, linear_to_db(value))
|
||||
|
||||
|
||||
func _input(event):
|
||||
if event.is_action_pressed("ui_cancel") or event.is_action_pressed("ui_menu_toggle"):
|
||||
|
||||
Reference in New Issue
Block a user