Feat: more predictable projet load behavior
This commit is contained in:
@@ -25,6 +25,8 @@ struct ProjectFile {
|
||||
sample_paths: Vec<PathBuf>,
|
||||
#[serde(default = "default_tempo")]
|
||||
tempo: f64,
|
||||
#[serde(default)]
|
||||
playing_patterns: Vec<(usize, usize)>,
|
||||
}
|
||||
|
||||
fn default_tempo() -> f64 {
|
||||
@@ -38,6 +40,7 @@ impl From<&Project> for ProjectFile {
|
||||
banks: project.banks.clone(),
|
||||
sample_paths: project.sample_paths.clone(),
|
||||
tempo: project.tempo,
|
||||
playing_patterns: project.playing_patterns.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,6 +51,7 @@ impl From<ProjectFile> for Project {
|
||||
banks: file.banks,
|
||||
sample_paths: file.sample_paths,
|
||||
tempo: file.tempo,
|
||||
playing_patterns: file.playing_patterns,
|
||||
};
|
||||
project.normalize();
|
||||
project
|
||||
|
||||
@@ -450,6 +450,8 @@ pub struct Project {
|
||||
pub sample_paths: Vec<PathBuf>,
|
||||
#[serde(default = "default_tempo")]
|
||||
pub tempo: f64,
|
||||
#[serde(default)]
|
||||
pub playing_patterns: Vec<(usize, usize)>,
|
||||
}
|
||||
|
||||
fn default_tempo() -> f64 {
|
||||
@@ -462,6 +464,7 @@ impl Default for Project {
|
||||
banks: (0..MAX_BANKS).map(|_| Bank::default()).collect(),
|
||||
sample_paths: Vec::new(),
|
||||
tempo: default_tempo(),
|
||||
playing_patterns: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user