1
0
Fork 0
mirror of https://github.com/doukutsu-rs/doukutsu-rs synced 2024-11-15 18:32:48 +00:00

Soundtrack menu improvements (#66)

This commit is contained in:
József Sallai 2022-02-23 23:37:02 +02:00 committed by GitHub
parent 5cf63660ef
commit 8a94c841c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -295,7 +295,21 @@ impl SettingsMenu {
let _ = state.settings.save(ctx); let _ = state.settings.save(ctx);
} }
} }
MenuSelectionResult::Selected(4, _) => self.current = CurrentMenu::SoundtrackMenu, MenuSelectionResult::Selected(4, _) => {
let mut active_soundtrack_index = 0;
for (idx, entry) in self.soundtrack.entries.iter().enumerate() {
if let MenuEntry::Active(soundtrack) = entry {
if soundtrack == &state.settings.soundtrack {
active_soundtrack_index = idx;
}
}
}
self.soundtrack.selected = active_soundtrack_index;
self.current = CurrentMenu::SoundtrackMenu
}
MenuSelectionResult::Selected(5, _) | MenuSelectionResult::Canceled => { MenuSelectionResult::Selected(5, _) | MenuSelectionResult::Canceled => {
self.current = CurrentMenu::MainMenu self.current = CurrentMenu::MainMenu
} }
@ -307,6 +321,7 @@ impl SettingsMenu {
MenuSelectionResult::Selected(idx, entry) => { MenuSelectionResult::Selected(idx, entry) => {
if let (true, MenuEntry::Active(name)) = (idx != last, entry) { if let (true, MenuEntry::Active(name)) = (idx != last, entry) {
state.settings.soundtrack = name.to_owned(); state.settings.soundtrack = name.to_owned();
let _ = state.settings.save(ctx);
self.sound.entries[4] = self.sound.entries[4] =
MenuEntry::Active(format!("Soundtrack: {}", state.settings.soundtrack)); MenuEntry::Active(format!("Soundtrack: {}", state.settings.soundtrack));
state.sound_manager.reload_songs(&state.constants, &state.settings, ctx)?; state.sound_manager.reload_songs(&state.constants, &state.settings, ctx)?;