diff --git a/src/main.rs b/src/main.rs index 9e63b89..132552e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -219,14 +219,16 @@ impl Game { if let Some(solution) = solutions.get_mut(self.selected_solution) { let column_x = level_list_width + entry_width + 20; let bounds = Rectangle::new(column_x as f32, y as f32, 220., 30.); - text_input( + if text_input( d, bounds, &mut solution.name, &mut self.editing_solution_name, 24, true, - ); + ){ + solution.save(); + } let id_text = format!("{}", solution.id()); d.draw_text(&id_text, column_x, y + 35, 10, Color::GRAY); diff --git a/src/solution.rs b/src/solution.rs index ffc9b89..09fdee8 100644 --- a/src/solution.rs +++ b/src/solution.rs @@ -49,7 +49,7 @@ impl Solution { pub fn save(&self) { let dir = userdata_dir().join("solutions").join(&self.level_id); fs::create_dir_all(&dir).unwrap(); - let path = dir.join(format!("{}.json", &self.solution_id)); + let path = dir.join(format!("solution_{}.json", &self.solution_id)); let json = serde_json::to_string_pretty(self).unwrap(); let mut file = File::create(path).unwrap();