Skip to content

Commit

Permalink
implemented keybinding for IO selection
Browse files Browse the repository at this point in the history
  • Loading branch information
alegnani committed Feb 11, 2024
1 parent f783c74 commit 3970717
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions verifactory_app/src/gui/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::{
path::PathBuf,
};

use egui::{Align2, Direction, Event};
use egui::{Align2, Direction, Event, InputState, Key};
use egui_file::FileDialog;
use egui_toast::{Toast, ToastOptions, Toasts};

Expand Down Expand Up @@ -209,37 +209,40 @@ impl eframe::App for MyApp {

let io_state = &mut self.io_state;
if let Some(sel) = self.selection {
let (i_pressed, o_pressed) =
ctx.input(|i: &InputState| (i.key_pressed(Key::I), i.key_pressed(Key::O)));
egui::SidePanel::right("right").show(ctx, |ui| {
let base = sel.get_base();
let id = base.id;
ui.heading("Entity information");
ui.separator();
ui.label(format!("Entity ID: {}", id));
ui.label(format!("Throughput: {}/s", base.throughput as i32));

ui.horizontal(|ui| {
if io_state.input_entities.contains(&id) {
ui.horizontal(|ui| {
ui.label("Selected as blueprint input");
if ui.button("Remove from input").clicked() {
if ui.button("Remove from input").clicked() || i_pressed {
io_state.input_entities.remove(&id);
}
});
} else if io_state.input_candidates.contains(&id) {
ui.label("Can be selected as blueprint input");
if ui.button("Select as input").clicked() {
if ui.button("Select as input").clicked() || i_pressed {
io_state.input_entities.insert(id);
}
}
});
ui.horizontal(|ui| {
if io_state.output_entities.contains(&id) {
ui.label("Selected as blueprint output");
if ui.button("Remove from output").clicked() {
if ui.button("Remove from output").clicked() || o_pressed {
io_state.output_entities.remove(&id);
}
} else if io_state.output_candidates.contains(&id) {
ui.label("Can be selected as blueprint output");
if ui.button("Select as output").clicked() {
if ui.button("Select as output").clicked() || o_pressed {
io_state.output_entities.insert(id);
}
}
Expand Down

0 comments on commit 3970717

Please sign in to comment.