From 281ce134c4be2bb2a70b651727fa9e10e93ac639 Mon Sep 17 00:00:00 2001 From: Pcornat Date: Sun, 30 Oct 2022 18:58:44 +0100 Subject: [PATCH] Adding a gui trait/interface for CharacterSheet. Goal: to interact with the gui in a shorter way. --- src/gui.rs | 13 +++++++++++++ src/lib.rs | 1 + src/main.rs | 6 ++---- 3 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 src/gui.rs diff --git a/src/gui.rs b/src/gui.rs new file mode 100644 index 0000000..e443dc0 --- /dev/null +++ b/src/gui.rs @@ -0,0 +1,13 @@ +use eframe::egui; +use eframe::egui::Ui; + +use crate::sheet::{Characteristic, CharacterSheet}; + +pub trait SheetGui 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_stamina(&mut self, ui: &mut Ui); + fn gui_luck(&mut self, ui: &mut Ui); + fn gui_skill(&mut self, ui: &mut Ui); + fn secondary_stats(&mut self, ui: &mut Ui); +} diff --git a/src/lib.rs b/src/lib.rs index 1cac971..17ebef3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1 +1,2 @@ pub mod sheet; +pub mod gui; diff --git a/src/main.rs b/src/main.rs index 6250a19..ffff12b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,7 +5,7 @@ fn main() { eframe::run_native( "Billy Sheet editor", options, - Box::new(|ctx| { + Box::new(|_ctx| { // ctx.egui_ctx.options().screen_reader = true; Box::new(Gui::default()) }), @@ -83,9 +83,7 @@ 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(); }