Compare commits

..

No commits in common. "542923ccef5678d88969816ec661206786ee9549" and "944f6c31b8848ec72f775d822c1c9bfbf407fe87" have entirely different histories.

2 changed files with 10 additions and 14 deletions

View file

@ -1,5 +1,4 @@
use eframe::egui; use eframe::egui;
use std::io::Write as _;
use billy_sheet::gui::SheetGui; use billy_sheet::gui::SheetGui;
@ -41,20 +40,16 @@ impl eframe::App for Gui {
_frame.close(); _frame.close();
} }
if ui.button("Save in json").clicked() { if ui.button("Save in json").clicked() {
let result = serde_json::to_string_pretty(&self.sheet); let sheet_str = serde_json::to_string(&self.sheet);
match result { let path = std::path::Path::new("./sheet.json");
Ok(sheet_str) => { if path.exists() {
let path = std::path::Path::new("./sheet.json"); if let Err(a) = std::fs::remove_file(path) {
match std::fs::File::create(path) { println!("{a}");
Ok(mut file) => { } else {
if let Err(err) = write!(file, "{}", sheet_str) {
println!("{err}");
}
}
Err(error) => println!("{error}"),
}
} }
Err(error) => println!("{error}"), } else {
} }
} }
}); });

View file

@ -2,6 +2,7 @@ use eframe::egui::widgets::DragValue;
use eframe::egui::Ui; use eframe::egui::Ui;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::gui::SheetGui; use crate::gui::SheetGui;
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]