From 927a904c72167f37f199fcbdc595a42817167bef Mon Sep 17 00:00:00 2001 From: Sofia Date: Tue, 28 Jul 2026 21:13:07 +0300 Subject: [PATCH] Make music loop --- rust/src/bgm.rs | 12 +++++++++++- rust/src/game_manager.rs | 2 +- rust/src/ui/lobby.rs | 2 +- rust/src/ui/main_menu.rs | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/rust/src/bgm.rs b/rust/src/bgm.rs index be3819a..678a63b 100644 --- a/rust/src/bgm.rs +++ b/rust/src/bgm.rs @@ -32,7 +32,17 @@ impl MusicManager { get_autoload_by_name::(MUSIC_MANAGER_GLOBAL) } - pub fn play(&mut self, music: Option) { + pub fn ready(&mut self) { + if let Some(player) = self.player.clone() { + player.signals().finished().connect_other(self, |s| { + if let Some(playing) = s.currently_playing { + s.play(Some(playing), true); + } + }); + } + } + + pub fn play(&mut self, music: Option, force: bool) { if self.currently_playing == music { return; } diff --git a/rust/src/game_manager.rs b/rust/src/game_manager.rs index b1be4f2..2e24b71 100644 --- a/rust/src/game_manager.rs +++ b/rust/src/game_manager.rs @@ -460,7 +460,7 @@ impl Game { } MusicManager::singleton() .bind_mut() - .play(Some(Music::Map(self.selected_map_idx))); + .play(Some(Music::Map(self.selected_map_idx)), false); self.run_deferred(|_| { if let Some(peer) = &mut NetworkManager::singleton().bind_mut().peer { diff --git a/rust/src/ui/lobby.rs b/rust/src/ui/lobby.rs index c7d3705..27f1297 100644 --- a/rust/src/ui/lobby.rs +++ b/rust/src/ui/lobby.rs @@ -192,7 +192,7 @@ impl IPanel for LobbyPanel { MusicManager::singleton() .bind_mut() - .play(Some(Music::MainMenu)); + .play(Some(Music::MainMenu), false); } } diff --git a/rust/src/ui/main_menu.rs b/rust/src/ui/main_menu.rs index c18c9f4..c3ec2b2 100644 --- a/rust/src/ui/main_menu.rs +++ b/rust/src/ui/main_menu.rs @@ -102,7 +102,7 @@ impl INode3D for MainMenu { MusicManager::singleton() .bind_mut() - .play(Some(Music::MainMenu)); + .play(Some(Music::MainMenu), false); } fn process(&mut self, _delta: f64) {