Compare commits
	
		
			2 commits
		
	
	
		
			
				542923ccef
			
			...
			
				877d300a5c
			
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
							 | 
						877d300a5c | ||
| 
							 | 
						05473a0a33 | 
					 2 changed files with 10 additions and 15 deletions
				
			
		
							
								
								
									
										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}"),
 | 
					 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
                });
 | 
					                });
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,7 @@
 | 
				
			||||||
use eframe::egui::widgets::DragValue;
 | 
					use eframe::egui::widgets::DragValue;
 | 
				
			||||||
use eframe::egui::Ui;
 | 
					use eframe::egui::Ui;
 | 
				
			||||||
use serde::{Deserialize, Serialize};
 | 
					use serde::{Deserialize, Serialize};
 | 
				
			||||||
 | 
					use std::io::Write as _;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use crate::gui::SheetGui;
 | 
					use crate::gui::SheetGui;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -36,6 +37,12 @@ pub struct CharacterSheet {
 | 
				
			||||||
    money: u32,
 | 
					    money: u32,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					pub fn write_sheet(path: &std::path::Path, sheet: &CharacterSheet) -> std::io::Result<()> {
 | 
				
			||||||
 | 
					    let sheet_str = serde_json::to_string_pretty(&sheet)?;
 | 
				
			||||||
 | 
					    let mut file = std::fs::File::create(path)?;
 | 
				
			||||||
 | 
					    write!(file, "{}", sheet_str)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl CharacterSheet {
 | 
					impl CharacterSheet {
 | 
				
			||||||
    pub fn character_class(&self) -> &Classe {
 | 
					    pub fn character_class(&self) -> &Classe {
 | 
				
			||||||
        &self.character_class
 | 
					        &self.character_class
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue