mirror of
https://github.com/doukutsu-rs/doukutsu-rs
synced 2024-11-25 23:12:56 +00:00
save prev bgm song id as well
This commit is contained in:
parent
d335c21f50
commit
f137d84a46
|
@ -22,6 +22,7 @@ mod wav;
|
|||
|
||||
pub struct SoundManager {
|
||||
tx: Sender<PlaybackMessage>,
|
||||
prev_song_id: usize,
|
||||
current_song_id: usize,
|
||||
}
|
||||
|
||||
|
@ -92,6 +93,7 @@ impl SoundManager {
|
|||
|
||||
Ok(SoundManager {
|
||||
tx: tx.clone(),
|
||||
prev_song_id: 0,
|
||||
current_song_id: 0,
|
||||
})
|
||||
}
|
||||
|
@ -110,6 +112,7 @@ impl SoundManager {
|
|||
let org = organya::Song::load_from(filesystem::open(ctx, ["/base/Org/", &song_name.to_lowercase(), ".org"].join(""))?)?;
|
||||
log::info!("Playing BGM: {}", song_name);
|
||||
|
||||
self.prev_song_id = self.current_song_id;
|
||||
self.current_song_id = song_id;
|
||||
self.tx.send(PlaybackMessage::SaveState)?;
|
||||
self.tx.send(PlaybackMessage::PlaySong(Box::new(org)))?;
|
||||
|
@ -119,12 +122,14 @@ impl SoundManager {
|
|||
|
||||
pub fn save_state(&mut self) -> GameResult {
|
||||
self.tx.send(PlaybackMessage::SaveState)?;
|
||||
self.prev_song_id = self.current_song_id;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn restore_state(&mut self) -> GameResult {
|
||||
self.tx.send(PlaybackMessage::RestoreState)?;
|
||||
self.current_song_id = self.prev_song_id;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue