Format
This commit is contained in:
parent
5514ecda67
commit
c489be9c78
15
.fleet/run.json
Normal file
15
.fleet/run.json
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"type": "cargo",
|
||||||
|
"name": "Build release",
|
||||||
|
"cargoArgs": ["build", "--release"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "cargo",
|
||||||
|
"name": "Run release",
|
||||||
|
"cargoArgs": ["run", "--release"],
|
||||||
|
},
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
32
Cargo.lock
generated
32
Cargo.lock
generated
@ -196,7 +196,8 @@ name = "billy_sheet"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"eframe",
|
"eframe",
|
||||||
"json",
|
"serde",
|
||||||
|
"serde_json",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1033,6 +1034,12 @@ dependencies = [
|
|||||||
"web-sys",
|
"web-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "itoa"
|
||||||
|
version = "1.0.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "jni"
|
name = "jni"
|
||||||
version = "0.19.0"
|
version = "0.19.0"
|
||||||
@ -1062,12 +1069,6 @@ dependencies = [
|
|||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "json"
|
|
||||||
version = "0.12.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "078e285eafdfb6c4b434e0d31e8cfcb5115b651496faca5749b88fafd4f23bfd"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "khronos_api"
|
name = "khronos_api"
|
||||||
version = "3.1.0"
|
version = "3.1.0"
|
||||||
@ -1623,6 +1624,12 @@ dependencies = [
|
|||||||
"ordered-multimap",
|
"ordered-multimap",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ryu"
|
||||||
|
version = "1.0.11"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "safe_arch"
|
name = "safe_arch"
|
||||||
version = "0.5.2"
|
version = "0.5.2"
|
||||||
@ -1685,6 +1692,17 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_json"
|
||||||
|
version = "1.0.89"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db"
|
||||||
|
dependencies = [
|
||||||
|
"itoa",
|
||||||
|
"ryu",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_repr"
|
name = "serde_repr"
|
||||||
version = "0.1.9"
|
version = "0.1.9"
|
||||||
|
@ -7,4 +7,5 @@ edition = "2021"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
eframe = { version = "*", features = ["dark-light"] }
|
eframe = { version = "*", features = ["dark-light"] }
|
||||||
json = "*"
|
serde = { version = "*", features = ["derive"] }
|
||||||
|
serde_json = "*"
|
||||||
|
17
src/gui.rs
17
src/gui.rs
@ -1,10 +1,19 @@
|
|||||||
use eframe::egui;
|
|
||||||
use eframe::egui::Ui;
|
use eframe::egui::Ui;
|
||||||
|
|
||||||
use crate::sheet::{Characteristic, CharacterSheet};
|
use crate::sheet::Characteristic;
|
||||||
|
|
||||||
pub trait SheetGui where Self: Sized {
|
pub trait SheetGui
|
||||||
fn shortcut(&self, _ui: &mut Ui, category: &str, character_field: &Characteristic) -> (u32, u32, u32) { (0, 0, 0) }
|
where
|
||||||
|
Self: Sized,
|
||||||
|
{
|
||||||
|
fn shortcut(
|
||||||
|
&self,
|
||||||
|
_ui: &mut Ui,
|
||||||
|
_category: &str,
|
||||||
|
_character_field: &Characteristic,
|
||||||
|
) -> (u32, u32, u32) {
|
||||||
|
(0, 0, 0)
|
||||||
|
}
|
||||||
fn gui_address(&mut self, ui: &mut Ui);
|
fn gui_address(&mut self, ui: &mut Ui);
|
||||||
fn gui_stamina(&mut self, ui: &mut Ui);
|
fn gui_stamina(&mut self, ui: &mut Ui);
|
||||||
fn gui_luck(&mut self, ui: &mut Ui);
|
fn gui_luck(&mut self, ui: &mut Ui);
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
pub mod sheet;
|
|
||||||
pub mod gui;
|
pub mod gui;
|
||||||
|
pub mod sheet;
|
||||||
|
@ -48,6 +48,7 @@ impl eframe::App for Gui {
|
|||||||
egui::CentralPanel::default().show(ctx, |ui| {
|
egui::CentralPanel::default().show(ctx, |ui| {
|
||||||
ui.heading("My egui Application");
|
ui.heading("My egui Application");
|
||||||
ui.separator();
|
ui.separator();
|
||||||
|
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.test.character().to_string();
|
||||||
ui.text_edit_multiline(&mut tmp_str);
|
ui.text_edit_multiline(&mut tmp_str);
|
||||||
@ -73,7 +74,9 @@ impl eframe::App for Gui {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
if ctx.input_mut().consume_key(egui::Modifiers::CTRL, egui::Key::Q)
|
if ctx
|
||||||
|
.input_mut()
|
||||||
|
.consume_key(egui::Modifiers::CTRL, egui::Key::Q)
|
||||||
{
|
{
|
||||||
_frame.close();
|
_frame.close();
|
||||||
}
|
}
|
||||||
|
79
src/sheet.rs
79
src/sheet.rs
@ -1,9 +1,10 @@
|
|||||||
use eframe::egui::Ui;
|
|
||||||
use eframe::egui::widgets::DragValue;
|
use eframe::egui::widgets::DragValue;
|
||||||
|
use eframe::egui::Ui;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::gui::SheetGui;
|
use crate::gui::SheetGui;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub enum Classe {
|
pub enum Classe {
|
||||||
Warrior,
|
Warrior,
|
||||||
Cautious,
|
Cautious,
|
||||||
@ -11,7 +12,7 @@ pub enum Classe {
|
|||||||
Resourceful,
|
Resourceful,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
enum CharacteristicType {
|
enum CharacteristicType {
|
||||||
Address,
|
Address,
|
||||||
Stamina,
|
Stamina,
|
||||||
@ -19,7 +20,7 @@ enum CharacteristicType {
|
|||||||
Skill,
|
Skill,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct CharacterSheet {
|
pub struct CharacterSheet {
|
||||||
character_class: Classe,
|
character_class: Classe,
|
||||||
/// Field to write the personality/
|
/// Field to write the personality/
|
||||||
@ -72,66 +73,76 @@ impl CharacterSheet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl SheetGui for CharacterSheet {
|
impl SheetGui for CharacterSheet {
|
||||||
fn shortcut(&self, ui: &mut Ui, category: &str, character_field: &Characteristic) -> (u32, u32, u32) {
|
fn shortcut(
|
||||||
|
&self,
|
||||||
|
ui: &mut Ui,
|
||||||
|
category: &str,
|
||||||
|
character_field: &Characteristic,
|
||||||
|
) -> (u32, u32, u32) {
|
||||||
let mut base = character_field.base;
|
let mut base = character_field.base;
|
||||||
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);
|
||||||
ui.columns(2, |columns| {
|
ui.horizontal(|ui| {
|
||||||
let mut ui_column = &mut columns[0];
|
ui.label("Base");
|
||||||
ui_column.label("Base");
|
ui.add(DragValue::new(&mut base));
|
||||||
ui_column.label("Carac.");
|
});
|
||||||
ui_column.label("Matériel");
|
ui.horizontal(|ui| {
|
||||||
|
ui.label("Carac.");
|
||||||
ui_column = &mut columns[1];
|
ui.add(DragValue::new(&mut carac));
|
||||||
ui_column.add(DragValue::new(&mut base));
|
});
|
||||||
ui_column.add(DragValue::new(&mut carac));
|
ui.horizontal(|ui| {
|
||||||
ui_column.add(DragValue::new(&mut materiel));
|
ui.label("Matériel");
|
||||||
|
ui.add(DragValue::new(&mut materiel));
|
||||||
});
|
});
|
||||||
return (base, carac, materiel);
|
return (base, carac, materiel);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gui_address(&mut self, ui: &mut Ui) {
|
fn gui_address(&mut self, ui: &mut Ui) {
|
||||||
let workaround: &CharacterSheet = self;
|
let workaround = self as &CharacterSheet;
|
||||||
(self.address.base, self.address.carac, self.address.materiel) = self.shortcut(ui, "Habileté", workaround.address());
|
(self.address.base, self.address.carac, self.address.materiel) =
|
||||||
|
self.shortcut(ui, "Adresse", workaround.address());
|
||||||
ui.label("Ne peut dépasser 5");
|
ui.label("Ne peut dépasser 5");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gui_stamina(&mut self, ui: &mut Ui) {
|
fn gui_stamina(&mut self, ui: &mut Ui) {
|
||||||
let workaround: &CharacterSheet = self;
|
let workaround = self as &CharacterSheet;
|
||||||
(self.stamina.base, self.stamina.carac, self.stamina.materiel) = self.shortcut(ui, "Endurance", workaround.stamina());
|
(self.stamina.base, self.stamina.carac, self.stamina.materiel) =
|
||||||
|
self.shortcut(ui, "Endurance", workaround.stamina());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gui_luck(&mut self, ui: &mut Ui) {
|
fn gui_luck(&mut self, ui: &mut Ui) {
|
||||||
let workaround: &CharacterSheet = self;
|
let workaround = self as &CharacterSheet;
|
||||||
(self.luck.base, self.luck.carac, self.luck.materiel) = self.shortcut(ui, "Chance", workaround.luck());
|
(self.luck.base, self.luck.carac, self.luck.materiel) =
|
||||||
|
self.shortcut(ui, "Chance", workaround.luck());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn gui_skill(&mut self, ui: &mut Ui) {
|
fn gui_skill(&mut self, ui: &mut Ui) {
|
||||||
let workaround: &CharacterSheet = self;
|
let workaround = self as &CharacterSheet;
|
||||||
(self.skill.base, self.skill.carac, self.skill.materiel) = self.shortcut(ui, "Habileté", workaround.skill());
|
(self.skill.base, self.skill.carac, self.skill.materiel) =
|
||||||
|
self.shortcut(ui, "Habileté", workaround.skill());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn secondary_stats(&mut self, ui: &mut Ui) {
|
fn secondary_stats(&mut self, ui: &mut Ui) {
|
||||||
let workaround: &CharacterSheet = self;
|
let workaround = self as &CharacterSheet;
|
||||||
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 damage = workaround.damage;
|
||||||
let mut armor = workaround.armor;
|
let mut armor = workaround.armor;
|
||||||
|
|
||||||
|
ui.heading("Stat. secondaires");
|
||||||
|
ui.horizontal(|ui| {
|
||||||
|
ui.label("Dégâts");
|
||||||
ui.add(DragValue::new(&mut damage));
|
ui.add(DragValue::new(&mut damage));
|
||||||
|
});
|
||||||
|
|
||||||
|
ui.horizontal(|ui| {
|
||||||
|
ui.label("Armure");
|
||||||
ui.add(DragValue::new(&mut armor));
|
ui.add(DragValue::new(&mut armor));
|
||||||
});
|
});
|
||||||
});
|
ui.label("Critique");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct Characteristic {
|
pub struct Characteristic {
|
||||||
characteristic_type: CharacteristicType,
|
characteristic_type: CharacteristicType,
|
||||||
pub base: u32,
|
pub base: u32,
|
||||||
|
Loading…
Reference in New Issue
Block a user