mirror of
https://github.com/doukutsu-rs/doukutsu-rs
synced 2024-10-31 19:44:20 +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 {
|
pub struct SoundManager {
|
||||||
tx: Sender<PlaybackMessage>,
|
tx: Sender<PlaybackMessage>,
|
||||||
|
prev_song_id: usize,
|
||||||
current_song_id: usize,
|
current_song_id: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,6 +93,7 @@ impl SoundManager {
|
||||||
|
|
||||||
Ok(SoundManager {
|
Ok(SoundManager {
|
||||||
tx: tx.clone(),
|
tx: tx.clone(),
|
||||||
|
prev_song_id: 0,
|
||||||
current_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(""))?)?;
|
let org = organya::Song::load_from(filesystem::open(ctx, ["/base/Org/", &song_name.to_lowercase(), ".org"].join(""))?)?;
|
||||||
log::info!("Playing BGM: {}", song_name);
|
log::info!("Playing BGM: {}", song_name);
|
||||||
|
|
||||||
|
self.prev_song_id = self.current_song_id;
|
||||||
self.current_song_id = song_id;
|
self.current_song_id = song_id;
|
||||||
self.tx.send(PlaybackMessage::SaveState)?;
|
self.tx.send(PlaybackMessage::SaveState)?;
|
||||||
self.tx.send(PlaybackMessage::PlaySong(Box::new(org)))?;
|
self.tx.send(PlaybackMessage::PlaySong(Box::new(org)))?;
|
||||||
|
@ -119,12 +122,14 @@ impl SoundManager {
|
||||||
|
|
||||||
pub fn save_state(&mut self) -> GameResult {
|
pub fn save_state(&mut self) -> GameResult {
|
||||||
self.tx.send(PlaybackMessage::SaveState)?;
|
self.tx.send(PlaybackMessage::SaveState)?;
|
||||||
|
self.prev_song_id = self.current_song_id;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn restore_state(&mut self) -> GameResult {
|
pub fn restore_state(&mut self) -> GameResult {
|
||||||
self.tx.send(PlaybackMessage::RestoreState)?;
|
self.tx.send(PlaybackMessage::RestoreState)?;
|
||||||
|
self.current_song_id = self.prev_song_id;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue