Compare commits
	
		
			2 commits
		
	
	
		
			
				944f6c31b8
			
			...
			
				542923ccef
			
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
							 | 
						542923ccef | ||
| 
							 | 
						9ed44a9a68 | 
					 2 changed files with 14 additions and 10 deletions
				
			
		
							
								
								
									
										23
									
								
								src/main.rs
									
										
									
									
									
								
							
							
						
						
									
										23
									
								
								src/main.rs
									
										
									
									
									
								
							| 
						 | 
					@ -1,4 +1,5 @@
 | 
				
			||||||
use eframe::egui;
 | 
					use eframe::egui;
 | 
				
			||||||
 | 
					use std::io::Write as _;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use billy_sheet::gui::SheetGui;
 | 
					use billy_sheet::gui::SheetGui;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -40,16 +41,20 @@ impl eframe::App for Gui {
 | 
				
			||||||
                        _frame.close();
 | 
					                        _frame.close();
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                    if ui.button("Save in json").clicked() {
 | 
					                    if ui.button("Save in json").clicked() {
 | 
				
			||||||
                        let sheet_str = serde_json::to_string(&self.sheet);
 | 
					                        let result = serde_json::to_string_pretty(&self.sheet);
 | 
				
			||||||
                        let path = std::path::Path::new("./sheet.json");
 | 
					                        match result {
 | 
				
			||||||
                        if path.exists() {
 | 
					                            Ok(sheet_str) => {
 | 
				
			||||||
                            if let Err(a) = std::fs::remove_file(path) {
 | 
					                                let path = std::path::Path::new("./sheet.json");
 | 
				
			||||||
                                println!("{a}");
 | 
					                                match std::fs::File::create(path) {
 | 
				
			||||||
                            } else {
 | 
					                                    Ok(mut file) => {
 | 
				
			||||||
                                
 | 
					                                        if let Err(err) = write!(file, "{}", sheet_str) {
 | 
				
			||||||
 | 
					                                            println!("{err}");
 | 
				
			||||||
 | 
					                                        }
 | 
				
			||||||
 | 
					                                    }
 | 
				
			||||||
 | 
					                                    Err(error) => println!("{error}"),
 | 
				
			||||||
 | 
					                                }
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        } else {
 | 
					                            Err(error) => println!("{error}"),
 | 
				
			||||||
 | 
					 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2,7 +2,6 @@ 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