Handling the writing of the character sheet.
This commit is contained in:
parent
05473a0a33
commit
877d300a5c
18
src/main.rs
18
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,9 @@ 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 path = std::path::Path::new("./sheet.json");
|
||||||
match result {
|
if let Err(error) = billy_sheet::sheet::write_sheet(path, &self.sheet) {
|
||||||
Ok(sheet_str) => {
|
println!("{error}");
|
||||||
let path = std::path::Path::new("./sheet.json");
|
|
||||||
match std::fs::File::create(path) {
|
|
||||||
Ok(mut file) => {
|
|
||||||
if let Err(err) = write!(file, "{}", sheet_str) {
|
|
||||||
println!("{err}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(error) => println!("{error}"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(error) => println!("{error}"),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user