Compare commits

...

4 Commits

Author SHA1 Message Date
4436c79c65
Reformat CRLF -> LF. Adding a WIP GUI too. 2022-10-30 13:17:00 +01:00
4ed370d51f
Adding getters. 2022-10-30 13:16:25 +01:00
b657e32cac
Reformat CRLF -> LF 2022-10-30 13:16:10 +01:00
8886c73316
New packages an dependencies. 2022-10-30 13:15:53 +01:00
4 changed files with 163 additions and 322 deletions

211
Cargo.lock generated
View File

@ -199,28 +199,6 @@ dependencies = [
"json",
]
[[package]]
name = "bindgen"
version = "0.61.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a022e58a142a46fea340d68012b9201c094e93ec3d033a944a24f8fd4a4f09a"
dependencies = [
"bitflags",
"cexpr",
"clang-sys",
"lazy_static",
"lazycell",
"log",
"peeking_take_while",
"proc-macro2",
"quote",
"regex",
"rustc-hash",
"shlex",
"syn",
"which",
]
[[package]]
name = "bitflags"
version = "1.3.2"
@ -302,15 +280,6 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c"
[[package]]
name = "cexpr"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
dependencies = [
"nom",
]
[[package]]
name = "cfg-if"
version = "1.0.0"
@ -326,17 +295,6 @@ dependencies = [
"libc",
]
[[package]]
name = "clang-sys"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa2e27ae6ab525c3d369ded447057bca5438d86dc3a68f6faafb8269ba82ebf3"
dependencies = [
"glob",
"libc",
"libloading",
]
[[package]]
name = "clipboard-win"
version = "4.4.2"
@ -634,33 +592,6 @@ dependencies = [
"wio",
]
[[package]]
name = "dyn-clonable"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e9232f0e607a262ceb9bd5141a3dfb3e4db6994b31989bbfd845878cba59fd4"
dependencies = [
"dyn-clonable-impl",
"dyn-clone",
]
[[package]]
name = "dyn-clonable-impl"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "558e40ea573c374cf53507fd240b7ee2f5477df7cfebdb97323ec61c719399c5"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "dyn-clone"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f94fa09c2aeea5b8839e414b7b841bf429fd25b9c522116ac97ee87856d88b2"
[[package]]
name = "eframe"
version = "0.19.0"
@ -678,7 +609,6 @@ dependencies = [
"js-sys",
"percent-encoding",
"tracing",
"tts",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
@ -708,7 +638,6 @@ dependencies = [
"instant",
"smithay-clipboard",
"tracing",
"tts",
"webbrowser",
"winit",
]
@ -728,12 +657,6 @@ dependencies = [
"web-sys",
]
[[package]]
name = "either"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797"
[[package]]
name = "emath"
version = "0.19.0"
@ -990,12 +913,6 @@ dependencies = [
"xml-rs",
]
[[package]]
name = "glob"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
[[package]]
name = "glow"
version = "0.11.2"
@ -1163,12 +1080,6 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]]
name = "lazycell"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
[[package]]
name = "libc"
version = "0.2.137"
@ -1428,7 +1339,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1"
dependencies = [
"malloc_buf",
"objc_exception",
]
[[package]]
@ -1442,15 +1352,6 @@ dependencies = [
"objc_id",
]
[[package]]
name = "objc_exception"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad970fb455818ad6cba4c122ad012fae53ae8b4795f86378bce65e4f6bab2ca4"
dependencies = [
"cc",
]
[[package]]
name = "objc_id"
version = "0.1.1"
@ -1533,12 +1434,6 @@ dependencies = [
"windows-sys 0.36.1",
]
[[package]]
name = "peeking_take_while"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
[[package]]
name = "percent-encoding"
version = "2.2.0"
@ -1728,12 +1623,6 @@ dependencies = [
"ordered-multimap",
]
[[package]]
name = "rustc-hash"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "safe_arch"
version = "0.5.2"
@ -1853,12 +1742,6 @@ dependencies = [
"libc",
]
[[package]]
name = "shlex"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3"
[[package]]
name = "slab"
version = "0.4.7"
@ -1922,25 +1805,6 @@ dependencies = [
"winapi",
]
[[package]]
name = "speech-dispatcher"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbab517fe176eb95d9bcc23c5ba75500fc5157d13a6978cfe135395fa149e151"
dependencies = [
"lazy_static",
"speech-dispatcher-sys",
]
[[package]]
name = "speech-dispatcher-sys"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c3e8acdf2b1f4bb13f1813b40b52f3edf4cc94d8a55fe713a584f672a10388d"
dependencies = [
"bindgen",
]
[[package]]
name = "static_assertions"
version = "1.1.0"
@ -2091,27 +1955,6 @@ version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ccbe8381883510b6a2d8f1e32905bddd178c11caef8083086d0c0c9ab0ac281"
[[package]]
name = "tts"
version = "0.20.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f14cef4d39fc1b2a69d163772c9015d6e33d694a1f1e2047ec32274675a17cb"
dependencies = [
"cocoa-foundation",
"dyn-clonable",
"jni",
"lazy_static",
"libc",
"log",
"ndk-glue 0.6.2",
"objc",
"speech-dispatcher",
"thiserror",
"wasm-bindgen",
"web-sys",
"windows",
]
[[package]]
name = "uds_windows"
version = "1.0.2"
@ -2377,17 +2220,6 @@ dependencies = [
"cc",
]
[[package]]
name = "which"
version = "4.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c831fbbee9e129a8cf93e7747a82da9d95ba8e16621cae60ec2cdc849bacb7b"
dependencies = [
"either",
"libc",
"once_cell",
]
[[package]]
name = "widestring"
version = "0.5.1"
@ -2434,19 +2266,6 @@ version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows"
version = "0.33.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0128fa8e65e0616e45033d68dc0b7fbd521080b7844e5cad3a4a4d201c4b2bd2"
dependencies = [
"windows_aarch64_msvc 0.33.0",
"windows_i686_gnu 0.33.0",
"windows_i686_msvc 0.33.0",
"windows_x86_64_gnu 0.33.0",
"windows_x86_64_msvc 0.33.0",
]
[[package]]
name = "windows-sys"
version = "0.36.1"
@ -2481,12 +2300,6 @@ version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e"
[[package]]
name = "windows_aarch64_msvc"
version = "0.33.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd761fd3eb9ab8cc1ed81e56e567f02dd82c4c837e48ac3b2181b9ffc5060807"
[[package]]
name = "windows_aarch64_msvc"
version = "0.36.1"
@ -2499,12 +2312,6 @@ version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4"
[[package]]
name = "windows_i686_gnu"
version = "0.33.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cab0cf703a96bab2dc0c02c0fa748491294bf9b7feb27e1f4f96340f208ada0e"
[[package]]
name = "windows_i686_gnu"
version = "0.36.1"
@ -2517,12 +2324,6 @@ version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7"
[[package]]
name = "windows_i686_msvc"
version = "0.33.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8cfdbe89cc9ad7ce618ba34abc34bbb6c36d99e96cae2245b7943cd75ee773d0"
[[package]]
name = "windows_i686_msvc"
version = "0.36.1"
@ -2535,12 +2336,6 @@ version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246"
[[package]]
name = "windows_x86_64_gnu"
version = "0.33.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4dd9b0c0e9ece7bb22e84d70d01b71c6d6248b81a3c60d11869451b4cb24784"
[[package]]
name = "windows_x86_64_gnu"
version = "0.36.1"
@ -2559,12 +2354,6 @@ version = "0.42.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028"
[[package]]
name = "windows_x86_64_msvc"
version = "0.33.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff1e4aa646495048ec7f3ffddc411e1d829c026a2ec62b39da15c1055e406eaa"
[[package]]
name = "windows_x86_64_msvc"
version = "0.36.1"

View File

@ -6,5 +6,5 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
eframe = { version = "*", features = ["screen_reader", "dark-light"] }
eframe = { version = "*", features = ["dark-light"] }
json = "*"

View File

@ -1,61 +1,76 @@
use eframe::egui;
fn main() {
let options = eframe::NativeOptions::default();
eframe::run_native(
"Billy Sheet editor",
options,
Box::new(|ctx| {
ctx.egui_ctx.options().screen_reader = true;
Box::new(Gui::default())
}),
);
let options = eframe::NativeOptions::default();
eframe::run_native(
"Billy Sheet editor",
options,
Box::new(|ctx| {
// ctx.egui_ctx.options().screen_reader = true;
Box::new(Gui::default())
}),
);
}
#[derive(Debug)]
struct Gui {
test: billy_sheet::sheet::CharacterSheet,
edit_mode: bool,
test: billy_sheet::sheet::CharacterSheet,
edit_mode: bool,
}
impl Default for Gui {
fn default() -> Self {
Self {
test: billy_sheet::sheet::CharacterSheet::default(),
edit_mode: true,
}
}
fn default() -> Self {
Self {
test: billy_sheet::sheet::CharacterSheet::default(),
edit_mode: true,
}
}
}
impl eframe::App for Gui {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::TopBottomPanel::top("menu").show(ctx, |ui| {
egui::menu::bar(ui, |ui| {
egui::widgets::global_dark_light_mode_buttons(ui);
ui.menu_button("File", |ui| {
if ui.button("Open (Ctrl + O)").clicked() {}
if ui.button("Quit (Ctrl + Q)").clicked() {
_frame.close();
}
});
if ui.button(format!("Edit mode {}", self.edit_mode)).clicked() {
self.edit_mode = !self.edit_mode;
}
});
});
egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("My egui Application");
ui.separator();
ui.vertical_centered_justified(|ui| {
ui.label("Hello");
// ui.text_edit_multiline(self.test.name());
});
});
if ctx
.input_mut()
.consume_key(egui::Modifiers::CTRL, egui::Key::Q)
{
_frame.close();
}
}
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::TopBottomPanel::top("menu").show(ctx, |ui| {
egui::menu::bar(ui, |ui| {
egui::widgets::global_dark_light_mode_buttons(ui);
ui.menu_button("File", |ui| {
if ui.button("Open (Ctrl + O)").clicked() {}
if ui.button("Quit (Ctrl + Q)").clicked() {
_frame.close();
}
});
if ui.button(format!("Edit mode {}", self.edit_mode)).clicked() {
self.edit_mode = !self.edit_mode.clone();
}
});
});
egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("My egui Application");
ui.separator();
ui.vertical_centered_justified(|ui| {
let mut tmp_str = self.test.character().to_string();
ui.text_edit_multiline(&mut tmp_str);
self.test.character = tmp_str;
});
ui.columns(2, |columns| {
// let mut col_1_ui = &mut columns[0];
// let mut col_2_ui = &mut columns[1];
columns[0].columns(2, |two_columns| {
// let mut in_col1 = &mut two_columns[0];
// let mut in_col2 = &mut two_columns[1];
two_columns[0].vertical_centered_justified(|ui| {
ui.heading("Habileté");
});
two_columns[1].vertical_centered_justified(|ui| {
ui.heading("Adresse");
});
});
});
});
if ctx
.input_mut()
.consume_key(egui::Modifiers::CTRL, egui::Key::Q)
{
_frame.close();
}
}
}

View File

@ -1,81 +1,118 @@
#[derive(Debug)]
pub enum Classe {
Warrior,
Cautious,
Farmer,
Resourceful,
Warrior,
Cautious,
Farmer,
Resourceful,
}
#[derive(Debug)]
enum CharacteristicType {
Address,
Stamina,
Luck,
Skill,
Address,
Stamina,
Luck,
Skill,
}
#[derive(Debug)]
pub struct CharacterSheet {
character_class: Classe,
name: String,
address: Characteristic,
stamina: Characteristic,
luck: Characteristic,
skill: Characteristic,
health: u32,
armor: u32,
damage: u32,
glory: u32,
money: u32,
character_class: Classe,
/// Field to write the personality/
pub character: String,
address: Characteristic,
stamina: Characteristic,
luck: Characteristic,
skill: Characteristic,
health: u32,
armor: u32,
damage: u32,
glory: u32,
money: u32,
}
impl CharacterSheet {
pub fn character_class(&self) -> &Classe {
&self.character_class
}
pub fn character(&self) -> &str {
&self.character
}
pub fn address(&self) -> &Characteristic {
&self.address
}
pub fn stamina(&self) -> &Characteristic {
&self.stamina
}
pub fn luck(&self) -> &Characteristic {
&self.luck
}
pub fn skill(&self) -> &Characteristic {
&self.skill
}
pub fn health(&self) -> u32 {
self.health
}
pub fn armor(&self) -> u32 {
self.armor
}
pub fn damage(&self) -> u32 {
self.damage
}
pub fn glory(&self) -> u32 {
self.glory
}
pub fn money(&self) -> u32 {
self.money
}
}
#[derive(Debug)]
pub struct Characteristic {
characteristic_type: CharacteristicType,
pub base: u32,
pub carac: u32,
pub materiel: u32,
pub additional: u32,
characteristic_type: CharacteristicType,
pub base: u32,
pub carac: u32,
pub materiel: u32,
pub additional: u32,
}
impl Default for CharacterSheet {
fn default() -> Self {
Self {
character_class: Classe::Warrior,
name: "Billy".to_string(),
address: Characteristic {
characteristic_type: CharacteristicType::Address,
base: 0,
carac: 0,
materiel: 0,
additional: 1,
},
stamina: Characteristic {
characteristic_type: CharacteristicType::Stamina,
base: 2,
carac: 0,
materiel: 0,
additional: 0,
},
luck: Characteristic {
characteristic_type: CharacteristicType::Luck,
base: 3,
carac: 0,
materiel: 0,
additional: 0,
},
skill: Characteristic {
characteristic_type: CharacteristicType::Skill,
base: 2,
carac: 0,
materiel: 0,
additional: 0,
},
health: 0,
armor: 0,
damage: 0,
glory: 0,
money: 0,
}
}
fn default() -> Self {
Self {
character_class: Classe::Warrior,
character: "Billy".to_string(),
address: Characteristic {
characteristic_type: CharacteristicType::Address,
base: 0,
carac: 0,
materiel: 0,
additional: 1,
},
stamina: Characteristic {
characteristic_type: CharacteristicType::Stamina,
base: 2,
carac: 0,
materiel: 0,
additional: 0,
},
luck: Characteristic {
characteristic_type: CharacteristicType::Luck,
base: 3,
carac: 0,
materiel: 0,
additional: 0,
},
skill: Characteristic {
characteristic_type: CharacteristicType::Skill,
base: 2,
carac: 0,
materiel: 0,
additional: 0,
},
health: 0,
armor: 0,
damage: 0,
glory: 0,
money: 0,
}
}
}