mirror of
https://github.com/doukutsu-rs/doukutsu-rs
synced 2025-11-27 22:56:15 +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 {
|
if song_id == 0 {
|
||||||
log::info!("Stopping BGM");
|
log::info!("Stopping BGM");
|
||||||
|
|
||||||
|
self.prev_song_id = self.current_song_id;
|
||||||
self.current_song_id = 0;
|
self.current_song_id = 0;
|
||||||
|
|
||||||
|
self.tx.send(PlaybackMessage::SaveState)?;
|
||||||
self.tx.send(PlaybackMessage::Stop)?;
|
self.tx.send(PlaybackMessage::Stop)?;
|
||||||
} else if let Some(song_name) = SONGS.get(song_id) {
|
} 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(""))?)?;
|
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);
|
engine.set_state(saved_state.clone().unwrap(), &bank);
|
||||||
saved_state = None;
|
saved_state = None;
|
||||||
|
|
||||||
|
if state == PlaybackState::Stopped {
|
||||||
|
engine.set_position(0);
|
||||||
|
}
|
||||||
|
|
||||||
for i in &mut buf[0..frames] { *i = 0x8080 };
|
for i in &mut buf[0..frames] { *i = 0x8080 };
|
||||||
frames = engine.render_to(&mut buf);
|
frames = engine.render_to(&mut buf);
|
||||||
index = 0;
|
index = 0;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue