Adding a gui trait/interface for CharacterSheet.

Goal: to interact with the gui in a shorter way.
This commit is contained in:
Pcornat 2022-10-30 18:58:44 +01:00
parent a8353ae3ee
commit 281ce134c4
Signed by: Pcornat
GPG Key ID: 2F3932FF46D9ECA0
3 changed files with 16 additions and 4 deletions

13
src/gui.rs Normal file
View File

@ -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);
}

View File

@ -1 +1,2 @@
pub mod sheet; pub mod sheet;
pub mod gui;

View File

@ -5,7 +5,7 @@ fn main() {
eframe::run_native( eframe::run_native(
"Billy Sheet editor", "Billy Sheet editor",
options, options,
Box::new(|ctx| { Box::new(|_ctx| {
// ctx.egui_ctx.options().screen_reader = true; // ctx.egui_ctx.options().screen_reader = true;
Box::new(Gui::default()) Box::new(Gui::default())
}), }),
@ -83,9 +83,7 @@ impl eframe::App for Gui {
}); });
}); });
}); });
if ctx if ctx.input_mut().consume_key(egui::Modifiers::CTRL, egui::Key::Q)
.input_mut()
.consume_key(egui::Modifiers::CTRL, egui::Key::Q)
{ {
_frame.close(); _frame.close();
} }