feat: implement settings menu, audio management system, and lobby UI framework

This commit is contained in:
Yogi Wiguna
2026-03-31 21:36:26 +08:00
parent 193aae94ba
commit cc19c7852d
15 changed files with 221 additions and 6 deletions
Binary file not shown.
+24
View File
@@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://du6b246jhn0tj"
path="res://.godot/imported/arena_bg_music.wav-12fe73cd56e22aeda5761a2108eff1b3.sample"
[deps]
source_file="res://assets/sounds/arena_bg_music.wav"
dest_files=["res://.godot/imported/arena_bg_music.wav-12fe73cd56e22aeda5761a2108eff1b3.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=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2
Binary file not shown.
+24
View File
@@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://dh8nshb7eap2c"
path="res://.godot/imported/freemode.wav-f4137aa9eff465cca78ac11ecfdf3ed1.sample"
[deps]
source_file="res://assets/sounds/freemode.wav"
dest_files=["res://.godot/imported/freemode.wav-f4137aa9eff465cca78ac11ecfdf3ed1.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=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2
Binary file not shown.
+24
View File
@@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://y2287if4tjr1"
path="res://.godot/imported/lobby.wav-c8ff7194593e906a687cb7ee25ec6f58.sample"
[deps]
source_file="res://assets/sounds/lobby.wav"
dest_files=["res://.godot/imported/lobby.wav-c8ff7194593e906a687cb7ee25ec6f58.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=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2
Binary file not shown.
+24
View File
@@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://coym874yjx4f7"
path="res://.godot/imported/stop_n_go.wav-04b2e929d323451f1207ed89f7615815.sample"
[deps]
source_file="res://assets/sounds/stop_n_go.wav"
dest_files=["res://.godot/imported/stop_n_go.wav-04b2e929d323451f1207ed89f7615815.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=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2
+1
View File
@@ -35,6 +35,7 @@ Satori="*uid://b8vev00s34b7"
SettingsManager="*uid://c1ouaaqnn0lrc"
SfxManager="*res://scripts/managers/sfx_manager.gd"
NameGenerator="*res://scripts/generators/name_generator.gd"
MusicManager="*res://scripts/managers/music_manager.gd"
[display]
+3 -4
View File
@@ -102,10 +102,9 @@ var _bot_names: Dictionary = {}
# var server_ip_input: LineEdit
func _ready():
# Check if user is authenticated (Commented out to allow server config on main menu)
# if not AuthManager.is_logged_in():
# call_deferred("_go_to_login")
# return
# Stop background music when in Lobby
MusicManager.stop_music()
# Load character textures
_load_character_textures()
+3 -1
View File
@@ -45,6 +45,9 @@ func _ready():
# Setup visual elevations for effects
_setup_effect_elevation()
# Start background music for the game mode
MusicManager.start_music()
# Setup UI
ui_manager.setup_playerboard_ui()
ui_manager.setup_timer_labels(self )
@@ -188,7 +191,6 @@ func _setup_effect_elevation():
em.mesh_library = ml
print("[Main] MeshLibrary elevation applied: Wall(4) and Freeze(5) at Y=0.8")
@rpc("any_peer", "call_local", "reliable")
func sync_portal_configs(configs: Array):
if portal_mode_manager:
+107
View File
@@ -0,0 +1,107 @@
extends Node
# MusicManager - Persistent singleton for handling background music across scenes
# Autoloaded as "MusicManager"
var music_player: AudioStreamPlayer
var current_track: String = ""
func _ready():
process_mode = Node.PROCESS_MODE_ALWAYS # Ensure music plays during pause
music_player = AudioStreamPlayer.new()
music_player.name = "BackgroundMusicPlayer"
music_player.bus = "Music"
add_child(music_player)
music_player.finished.connect(_on_music_finished)
# Do NOT auto-start music here anymore as per user request
# We will call start_music() from Main scene
# Connect to LobbyManager signals if it exists
if has_node("/root/LobbyManager"):
get_node("/root/LobbyManager").game_mode_changed.connect(_on_game_mode_changed)
func _on_game_mode_changed(_mode: String):
start_music()
func start_music():
var current_scene = get_tree().current_scene
if not current_scene:
return
if current_scene.name == "Lobby":
play_track("res://assets/sounds/lobby.wav")
return
if current_scene.name != "Main" and current_scene.name != "LoadingScreen":
print("[MusicManager] Not in Main or Lobby scene (currently in ", current_scene.name, "), skipping music.")
return
var game_mode = "Freemode"
if has_node("/root/LobbyManager"):
game_mode = get_node("/root/LobbyManager").game_mode
var track_path = ""
match game_mode:
"Stop n Go":
track_path = "res://assets/sounds/stop_n_go.wav"
"Freemode", "Tekton Doors", _:
track_path = "res://assets/sounds/freemode.wav"
play_track(track_path)
func play_track(track_path: String):
print("[MusicManager] Attempting to play track: ", track_path)
if current_track == track_path and music_player.playing:
print("[MusicManager] Already playing this track, skipping.")
return
if track_path == "":
print("[MusicManager] Empty track path, stopping music.")
music_player.stop()
current_track = ""
return
if not ResourceLoader.exists(track_path):
print("[MusicManager] ERROR: Track file not found: ", track_path)
return
var stream = load(track_path)
if not stream:
print("[MusicManager] ERROR: Failed to load stream from: ", track_path)
return
if stream is AudioStreamWAV:
# Godot 4 looping settings for WAV
stream.loop_mode = AudioStreamWAV.LOOP_FORWARD
# Ensure loop end is at the very end of the file if not set
if stream.loop_end == 0:
stream.loop_end = stream.data.size() # This is a guess, but loop_mode 1 usually handles it
print("[MusicManager] Configured WAV loop mode for: ", track_path)
music_player.stream = stream
# Verify bus exists before playing
var bus_idx = AudioServer.get_bus_index("Music")
if bus_idx == -1:
print("[MusicManager] Warning: 'Music' bus not found, falling back to 'Master'")
music_player.bus = "Master"
else:
music_player.bus = "Music"
music_player.play()
current_track = track_path
print("[MusicManager] play() called successfully for: ", track_path, " on bus: ", music_player.bus)
func stop_music():
music_player.stop()
current_track = ""
func _on_music_finished():
print("[MusicManager] Track finished: ", current_track)
# Fallback looping if for some reason the native loop didn't work
if current_track != "":
print("[MusicManag
+1
View File
@@ -0,0 +1 @@
uid://d02o4qmj5ttcg
+9
View File
@@ -154,10 +154,19 @@ func apply_video_settings():
func apply_audio_settings():
var audio = settings.audio
print("[SettingsManager] Applying audio settings: ", audio)
set_bus_volume("Master", audio.master_volume)
set_bus_volume("Music", audio.music_volume)
set_bus_volume("SFX", audio.sfx_volume)
# Explicitly ensure Music and SFX are routed to Master if they exist
var master_idx = AudioServer.get_bus_index("Master")
if master_idx != -1:
var music_idx = AudioServer.get_bus_index("Music")
if music_idx != -1: AudioServer.set_bus_send(music_idx, "Master")
var sfx_idx = AudioServer.get_bus_index("SFX")
if sfx_idx != -1: AudioServer.set_bus_send(sfx_idx, "Master")
func set_bus_volume(bus_name: String, volume_linear: float):
var bus_idx = AudioServer.get_bus_index(bus_name)
if bus_idx != -1:
+1 -1
View File
@@ -145,7 +145,7 @@ func _on_video_property_changed(idx: int, property_name: String):
SettingsManager.save_settings()
SettingsManager.apply_video_settings()
func _on_audio_setting_changed(key: String, value: float):
func _on_audio_setting_changed(value: float, key: String):
SettingsManager.settings.audio[key] = value
SettingsManager.save_settings()
SettingsManager.apply_audio_settings()