mirror of
https://github.com/doukutsu-rs/doukutsu-rs
synced 2024-10-31 19:44:20 +00:00
refactor CS+ soundtrack loading (#79)
This commit is contained in:
parent
62efbf0cc3
commit
d2a671e04c
|
@ -203,6 +203,13 @@ pub struct AnimatedFace {
|
|||
pub anim_frames: Vec<(u16, u16)>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ExtraSoundtrack {
|
||||
pub name: String,
|
||||
pub path: String,
|
||||
pub available: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct TextScriptConsts {
|
||||
pub encoding: TextScriptEncoding,
|
||||
|
@ -298,7 +305,7 @@ pub struct EngineConstants {
|
|||
pub font_path: String,
|
||||
pub font_scale: f32,
|
||||
pub font_space_offset: f32,
|
||||
pub soundtracks: HashMap<String, String>,
|
||||
pub soundtracks: Vec<ExtraSoundtrack>,
|
||||
pub music_table: Vec<String>,
|
||||
pub organya_paths: Vec<String>,
|
||||
pub credit_illustration_paths: Vec<String>,
|
||||
|
@ -1552,7 +1559,12 @@ impl EngineConstants {
|
|||
font_path: "csfont.fnt".to_owned(),
|
||||
font_scale: 1.0,
|
||||
font_space_offset: 0.0,
|
||||
soundtracks: HashMap::new(),
|
||||
soundtracks: vec![
|
||||
ExtraSoundtrack { name: "Remastered".to_owned(), path: "/base/Ogg11/".to_owned(), available: false },
|
||||
ExtraSoundtrack { name: "New".to_owned(), path: "/base/Ogg/".to_owned(), available: false },
|
||||
ExtraSoundtrack { name: "Famitracks".to_owned(), path: "/base/ogg17/".to_owned(), available: false },
|
||||
ExtraSoundtrack { name: "Ridiculon".to_owned(), path: "/base/ogg_ridic/".to_owned(), available: false },
|
||||
],
|
||||
music_table: vec![
|
||||
"xxxx".to_owned(),
|
||||
"wanpaku".to_owned(),
|
||||
|
@ -1639,8 +1651,6 @@ impl EngineConstants {
|
|||
|
||||
self.font_path = "csfont.fnt".to_owned();
|
||||
self.font_scale = 0.5;
|
||||
self.soundtracks.insert("Remastered".to_owned(), "/base/Ogg11/".to_owned());
|
||||
self.soundtracks.insert("New".to_owned(), "/base/Ogg/".to_owned());
|
||||
|
||||
let typewriter_sample = PixToneParameters {
|
||||
// fx2 (CS+)
|
||||
|
@ -1688,8 +1698,6 @@ impl EngineConstants {
|
|||
self.textscript.text_speed_normal = 1;
|
||||
self.textscript.text_speed_fast = 0;
|
||||
self.textscript.fade_ticks = 21;
|
||||
self.soundtracks.insert("Famitracks".to_owned(), "/base/ogg17/".to_owned());
|
||||
self.soundtracks.insert("Ridiculon".to_owned(), "/base/ogg_ridic/".to_owned());
|
||||
self.game.tile_offset_x = 3;
|
||||
self.game.new_game_player_pos = (13, 8);
|
||||
}
|
||||
|
|
|
@ -109,7 +109,8 @@ impl SettingsMenu {
|
|||
self.sound.push_entry(MenuEntry::Active(format!("Soundtrack: {}", state.settings.soundtrack)));
|
||||
self.sound.push_entry(MenuEntry::Active("< Back".to_owned()));
|
||||
|
||||
let mut soundtrack_entries = state.constants.soundtracks.keys().map(|s| s.to_owned()).collect_vec();
|
||||
let mut soundtrack_entries =
|
||||
state.constants.soundtracks.iter().filter(|s| s.available).map(|s| s.name.to_owned()).collect_vec();
|
||||
soundtrack_entries.push("Organya".to_owned());
|
||||
|
||||
if let Ok(dir) = filesystem::read_dir(ctx, "/Soundtracks/") {
|
||||
|
|
|
@ -68,7 +68,8 @@ impl Scene for JukeboxScene {
|
|||
|
||||
self.song_list = state.constants.music_table.iter().filter(|song| !song.contains("fanfale")).cloned().collect();
|
||||
|
||||
let mut soundtrack_entries = state.constants.soundtracks.keys().map(|s| s.to_owned()).collect_vec();
|
||||
let mut soundtrack_entries =
|
||||
state.constants.soundtracks.iter().filter(|s| s.available).map(|s| s.name.to_owned()).collect_vec();
|
||||
soundtrack_entries.push("Organya".to_owned());
|
||||
|
||||
if let Ok(dir) = filesystem::read_dir(ctx, "/Soundtracks/") {
|
||||
|
|
|
@ -233,6 +233,13 @@ impl SharedGameState {
|
|||
info!("NXEngine-evo data files detected.");
|
||||
}
|
||||
|
||||
for soundtrack in constants.soundtracks.iter_mut() {
|
||||
if filesystem::exists(ctx, &soundtrack.path) {
|
||||
info!("Enabling soundtrack {} from {}.", soundtrack.name, soundtrack.path);
|
||||
soundtrack.available = true;
|
||||
}
|
||||
}
|
||||
|
||||
let season = Season::current();
|
||||
constants.rebuild_path_list(None, season, &settings);
|
||||
|
||||
|
|
|
@ -200,8 +200,10 @@ impl SoundManager {
|
|||
|
||||
paths.insert(0, "/Soundtracks/".to_owned() + &settings.soundtrack + "/");
|
||||
|
||||
if let Some(soundtrack) = constants.soundtracks.get(&settings.soundtrack) {
|
||||
paths.insert(0, soundtrack.clone());
|
||||
if let Some(soundtrack) =
|
||||
constants.soundtracks.iter().find(|s| s.available && s.name == settings.soundtrack)
|
||||
{
|
||||
paths.insert(0, soundtrack.path.clone());
|
||||
}
|
||||
|
||||
let songs_paths = paths.iter().map(|prefix| {
|
||||
|
|
Loading…
Reference in a new issue