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:
parent
da9bcd3249
commit
4e57455a96
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue