setting up the level builder for generating levels from the save file

main
aprzn 2 years ago
parent 5af1552635
commit 33423cbf49

@ -36,7 +36,36 @@ pub fn gd_path() -> PathBuf {
path_buf path_buf
} }
fn load_levels() -> Vec<Level> {
struct LevelBuilder {
name: Option<String>,
song: Option<Song>,
}
impl Default for LevelBuilder {
fn default() -> Self {
Self {name: None, song: None}
}
}
impl LevelBuilder {
fn with_name(&mut self, name: String) {
self.name = Some(name);
}
fn with_song(&mut self, song: Song) {
self.song = Some(song);
}
fn make_level(self) -> Option<Level> {
if let Some(name) = self.name {
if let Some(song) = self.song {
return Some(Level {name, song});
}
}
None
}
}
fn get_levels() -> Vec<Level> {
let raw_save_data = { let raw_save_data = {
let mut save_file = File::open(gd_path().join("CCLocalLevels.dat")).expect("No save file found!"); let mut save_file = File::open(gd_path().join("CCLocalLevels.dat")).expect("No save file found!");
let mut sd = Vec::new(); let mut sd = Vec::new();

Loading…
Cancel
Save