1
0
Fork 0
mirror of https://github.com/doukutsu-rs/doukutsu-rs synced 2024-11-22 13:42:47 +00:00

restore state if music has been stopped

This commit is contained in:
Alula 2020-09-05 04:54:43 +02:00
parent da9bcd3249
commit 4e57455a96
No known key found for this signature in database
GPG key ID: 3E00485503A1D8BA

View file

@ -106,7 +106,10 @@ impl SoundManager {
if song_id == 0 {
log::info!("Stopping BGM");
self.prev_song_id = self.current_song_id;
self.current_song_id = 0;
self.tx.send(PlaybackMessage::SaveState)?;
self.tx.send(PlaybackMessage::Stop)?;
} else if let Some(song_name) = SONGS.get(song_id) {
let org = organya::Song::load_from(filesystem::open(ctx, ["/base/Org/", &song_name.to_lowercase(), ".org"].join(""))?)?;
@ -206,6 +209,10 @@ fn run<T>(rx: Receiver<PlaybackMessage>, bank: SoundBank,
engine.set_state(saved_state.clone().unwrap(), &bank);
saved_state = None;
if state == PlaybackState::Stopped {
engine.set_position(0);
}
for i in &mut buf[0..frames] { *i = 0x8080 };
frames = engine.render_to(&mut buf);
index = 0;