Complete merge with stash

This commit is contained in:
Florent DENEF 2022-11-29 16:19:33 +01:00
parent e4dc131808
commit 564ccfad88
5 changed files with 39 additions and 2633 deletions

14
.gitignore vendored
View File

@ -1,2 +1,16 @@
/target /target
.idea .idea
# Generated by Cargo
# will have compiled files and executables
debug/
target/
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock
# These are backup files generated by rustfmt
**/*.rs.bk
# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

2563
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -7,5 +7,7 @@ edition = "2021"
[dependencies] [dependencies]
eframe = { version = "*", features = ["dark-light"] } eframe = { version = "*", features = ["dark-light"] }
egui = { version = "*", features = ["deadlock_detection"]}
json = "*"
serde = { version = "*", features = ["derive"] } serde = { version = "*", features = ["derive"] }
serde_json = "*" serde_json = "*"

View File

@ -16,14 +16,14 @@ fn main() {
#[derive(Debug)] #[derive(Debug)]
struct Gui { struct Gui {
test: billy_sheet::sheet::CharacterSheet, sheet: billy_sheet::sheet::CharacterSheet,
edit_mode: bool, edit_mode: bool,
} }
impl Default for Gui { impl Default for Gui {
fn default() -> Self { fn default() -> Self {
Self { Self {
test: billy_sheet::sheet::CharacterSheet::default(), sheet: billy_sheet::sheet::CharacterSheet::default(),
edit_mode: true, edit_mode: true,
} }
} }
@ -39,6 +39,19 @@ impl eframe::App for Gui {
if ui.button("Quit (Ctrl + Q)").clicked() { if ui.button("Quit (Ctrl + Q)").clicked() {
_frame.close(); _frame.close();
} }
if ui.button("Save in json").clicked() {
let sheet_str = serde_json::to_string(&self.sheet);
let path = std::path::Path::new("./sheet.json");
if path.exists() {
if let Err(a) = std::fs::remove_file(path) {
println!("{a}");
} else {
}
} else {
}
}
}); });
if ui.button(format!("Edit mode {}", self.edit_mode)).clicked() { if ui.button(format!("Edit mode {}", self.edit_mode)).clicked() {
self.edit_mode = !self.edit_mode; self.edit_mode = !self.edit_mode;
@ -50,9 +63,9 @@ impl eframe::App for Gui {
ui.separator(); ui.separator();
ui.label("Caractère"); ui.label("Caractère");
ui.vertical_centered_justified(|ui| { ui.vertical_centered_justified(|ui| {
let mut tmp_str = self.test.character().to_string(); let mut tmp_str = self.sheet.character().to_string();
ui.text_edit_multiline(&mut tmp_str); ui.text_edit_multiline(&mut tmp_str);
self.test.character = tmp_str; self.sheet.character = tmp_str;
}); });
ui.columns(2, |columns| { ui.columns(2, |columns| {
// let mut col_1_ui = &mut columns[0]; // let mut col_1_ui = &mut columns[0];
@ -61,16 +74,16 @@ impl eframe::App for Gui {
// let mut in_col1 = &mut two_columns[0]; // let mut in_col1 = &mut two_columns[0];
// let mut in_col2 = &mut two_columns[1]; // let mut in_col2 = &mut two_columns[1];
two_columns[0].vertical_centered_justified(|ui| { two_columns[0].vertical_centered_justified(|ui| {
self.test.gui_skill(ui); self.sheet.gui_skill(ui);
self.test.gui_stamina(ui); self.sheet.gui_stamina(ui);
}); });
two_columns[1].vertical_centered_justified(|ui| { two_columns[1].vertical_centered_justified(|ui| {
self.test.gui_address(ui); self.sheet.gui_address(ui);
self.test.gui_luck(ui); self.sheet.gui_luck(ui);
}); });
}); });
columns[1].vertical_centered_justified(|ui| { columns[1].vertical_centered_justified(|ui| {
self.test.secondary_stats(ui); self.sheet.secondary_stats(ui);
}); });
}); });
}); });

View File

@ -1,9 +1,7 @@
use eframe::egui::widgets::DragValue; use eframe::egui::widgets::DragValue;
use eframe::egui::Ui; use eframe::egui::Ui;
<<<<<<< HEAD
=======
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
>>>>>>> 281e4eb9f0a44494530a7bc3422fcd557a26088f use serde_json::Result;
use crate::gui::SheetGui; use crate::gui::SheetGui;
@ -86,63 +84,6 @@ impl SheetGui for CharacterSheet {
let mut carac = character_field.carac; let mut carac = character_field.carac;
let mut materiel = character_field.materiel; let mut materiel = character_field.materiel;
ui.heading(category); ui.heading(category);
<<<<<<< HEAD
ui.columns(2, |columns| {
let mut ui_column = &mut columns[0];
ui_column.label("Base");
ui_column.label("Carac.");
ui_column.label("Matériel");
ui_column = &mut columns[1];
ui_column.add(DragValue::new(&mut base));
ui_column.add(DragValue::new(&mut carac));
ui_column.add(DragValue::new(&mut materiel));
});
return (base, carac, materiel);
}
fn gui_address(&mut self, ui: &mut Ui) {
let workaround: &CharacterSheet = self;
(self.address.base, self.address.carac, self.address.materiel) =
self.shortcut(ui, "Habileté", workaround.address());
ui.label("Ne peut dépasser 5");
}
fn gui_stamina(&mut self, ui: &mut Ui) {
let workaround: &CharacterSheet = self;
(self.stamina.base, self.stamina.carac, self.stamina.materiel) =
self.shortcut(ui, "Endurance", workaround.stamina());
}
fn gui_luck(&mut self, ui: &mut Ui) {
let workaround: &CharacterSheet = self;
(self.luck.base, self.luck.carac, self.luck.materiel) =
self.shortcut(ui, "Chance", workaround.luck());
}
fn gui_skill(&mut self, ui: &mut Ui) {
let workaround: &CharacterSheet = self;
(self.skill.base, self.skill.carac, self.skill.materiel) =
self.shortcut(ui, "Habileté", workaround.skill());
}
fn secondary_stats(&mut self, ui: &mut Ui) {
let workaround: &CharacterSheet = self;
ui.heading("Stat. secondaires");
ui.columns(2, |columns| {
columns[0].vertical_centered_justified(|ui| {
ui.label("Dégâts");
ui.label("Armure");
ui.label("Critique");
});
columns[1].vertical_centered_justified(|ui| {
let mut damage = workaround.damage;
let mut armor = workaround.armor;
ui.add(DragValue::new(&mut damage));
ui.add(DragValue::new(&mut armor));
});
});
=======
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.label("Base"); ui.label("Base");
ui.add(DragValue::new(&mut base)); ui.add(DragValue::new(&mut base));
@ -199,7 +140,6 @@ impl SheetGui for CharacterSheet {
ui.add(DragValue::new(&mut armor)); ui.add(DragValue::new(&mut armor));
}); });
ui.label("Critique"); ui.label("Critique");
>>>>>>> 281e4eb9f0a44494530a7bc3422fcd557a26088f
} }
} }