Compare commits
No commits in common. "542923ccef5678d88969816ec661206786ee9549" and "944f6c31b8848ec72f775d822c1c9bfbf407fe87" have entirely different histories.
542923ccef
...
944f6c31b8
2 changed files with 10 additions and 14 deletions
21
src/main.rs
21
src/main.rs
|
@ -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 {
|
|
||||||
Ok(sheet_str) => {
|
|
||||||
let path = std::path::Path::new("./sheet.json");
|
let path = std::path::Path::new("./sheet.json");
|
||||||
match std::fs::File::create(path) {
|
if path.exists() {
|
||||||
Ok(mut file) => {
|
if let Err(a) = std::fs::remove_file(path) {
|
||||||
if let Err(err) = write!(file, "{}", sheet_str) {
|
println!("{a}");
|
||||||
println!("{err}");
|
} else {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
Err(error) => println!("{error}"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(error) => println!("{error}"),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -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)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue