Reformat with cargo fmt
This commit is contained in:
parent
505aed8138
commit
fbf3d3815c
17
.fleet/run.json
Normal file
17
.fleet/run.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"type": "cargo",
|
||||
"name": "Run Release",
|
||||
"workingDir": ".",
|
||||
"cargoArgs": ["run", "--release"],
|
||||
},
|
||||
{
|
||||
"type": "cargo",
|
||||
"name": "Build Release",
|
||||
"cargoArgs": ["build", "--release"],
|
||||
},
|
||||
|
||||
|
||||
]
|
||||
}
|
27
src/gui.rs
27
src/gui.rs
@ -1,13 +1,22 @@
|
||||
use eframe::egui;
|
||||
use eframe::egui::Ui;
|
||||
|
||||
use crate::sheet::{Characteristic, CharacterSheet};
|
||||
use crate::sheet::Characteristic;
|
||||
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
@ -1,2 +1,2 @@
|
||||
pub mod sheet;
|
||||
pub mod gui;
|
||||
pub mod sheet;
|
||||
|
132
src/main.rs
132
src/main.rs
@ -3,79 +3,81 @@ use eframe::egui;
|
||||
use billy_sheet::gui::SheetGui;
|
||||
|
||||
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.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| {
|
||||
self.test.gui_skill(ui);
|
||||
self.test.gui_stamina(ui);
|
||||
});
|
||||
two_columns[1].vertical_centered_justified(|ui| {
|
||||
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)
|
||||
{
|
||||
_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| {
|
||||
self.test.gui_skill(ui);
|
||||
self.test.gui_stamina(ui);
|
||||
});
|
||||
two_columns[1].vertical_centered_justified(|ui| {
|
||||
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)
|
||||
{
|
||||
_frame.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user