diff --git a/src/gd.rs b/src/gd.rs index 5cea5de..65dd1e2 100644 --- a/src/gd.rs +++ b/src/gd.rs @@ -36,7 +36,36 @@ pub fn gd_path() -> PathBuf { path_buf } -fn load_levels() -> Vec { + +struct LevelBuilder { + name: Option, + song: Option, +} + +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 { + if let Some(name) = self.name { + if let Some(song) = self.song { + return Some(Level {name, song}); + } + } + None + } +} + +fn get_levels() -> Vec { let raw_save_data = { let mut save_file = File::open(gd_path().join("CCLocalLevels.dat")).expect("No save file found!"); let mut sd = Vec::new();