Implementing the GUI with the SheetGui interface.
This commit is contained in:
parent
281ce134c4
commit
5514ecda67
28
src/main.rs
28
src/main.rs
@ -1,5 +1,7 @@
|
|||||||
use eframe::egui;
|
use eframe::egui;
|
||||||
|
|
||||||
|
use billy_sheet::gui::SheetGui;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let options = eframe::NativeOptions::default();
|
let options = eframe::NativeOptions::default();
|
||||||
eframe::run_native(
|
eframe::run_native(
|
||||||
@ -58,29 +60,17 @@ 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| {
|
||||||
ui.heading("Habileté");
|
self.test.gui_skill(ui);
|
||||||
ui.columns(2, |columns| {
|
self.test.gui_stamina(ui);
|
||||||
let mut column = &mut columns[0];
|
|
||||||
{
|
|
||||||
column.label("Base");
|
|
||||||
column.label("Carac.");
|
|
||||||
column.label("Matériel");
|
|
||||||
}
|
|
||||||
column = &mut columns[1];
|
|
||||||
{
|
|
||||||
let mut base = self.test.skill().base;
|
|
||||||
let mut carac = self.test.skill().carac;
|
|
||||||
let mut materiel = self.test.skill().materiel;
|
|
||||||
column.add(egui::widgets::DragValue::new(&mut base));
|
|
||||||
column.add(egui::widgets::DragValue::new(&mut carac));
|
|
||||||
column.add(egui::widgets::DragValue::new(&mut materiel));
|
|
||||||
}
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
two_columns[1].vertical_centered_justified(|ui| {
|
two_columns[1].vertical_centered_justified(|ui| {
|
||||||
ui.heading("Adresse");
|
self.test.gui_address(ui);
|
||||||
|
self.test.gui_luck(ui);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
columns[1].vertical_centered_justified(|ui| {
|
||||||
|
self.test.secondary_stats(ui);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
if ctx.input_mut().consume_key(egui::Modifiers::CTRL, egui::Key::Q)
|
if ctx.input_mut().consume_key(egui::Modifiers::CTRL, egui::Key::Q)
|
||||||
|
65
src/sheet.rs
65
src/sheet.rs
@ -1,3 +1,8 @@
|
|||||||
|
use eframe::egui::Ui;
|
||||||
|
use eframe::egui::widgets::DragValue;
|
||||||
|
|
||||||
|
use crate::gui::SheetGui;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Classe {
|
pub enum Classe {
|
||||||
Warrior,
|
Warrior,
|
||||||
@ -66,6 +71,66 @@ impl CharacterSheet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl SheetGui for CharacterSheet {
|
||||||
|
fn shortcut(&self, ui: &mut Ui, category: &str, character_field: &Characteristic) -> (u32, u32, u32) {
|
||||||
|
let mut base = character_field.base;
|
||||||
|
let mut carac = character_field.carac;
|
||||||
|
let mut materiel = character_field.materiel;
|
||||||
|
ui.heading(category);
|
||||||
|
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));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Characteristic {
|
pub struct Characteristic {
|
||||||
characteristic_type: CharacteristicType,
|
characteristic_type: CharacteristicType,
|
||||||
|
Loading…
Reference in New Issue
Block a user