summaryrefslogtreecommitdiff
path: root/src/renderer/ui.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/renderer/ui.rs')
-rw-r--r--src/renderer/ui.rs64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/renderer/ui.rs b/src/renderer/ui.rs
new file mode 100644
index 0000000..87ab878
--- /dev/null
+++ b/src/renderer/ui.rs
@@ -0,0 +1,64 @@
+use egui::{Color32, Stroke, Ui, epaint::CircleShape};
+
+use crate::{Camera, Config, Diagnostics, Input, sim::materials::MaterialId};
+
+pub fn draw_egui<'a>(
+ ui: &mut Ui,
+ config: &mut Config,
+ camera: &mut Camera,
+ diagnostics: &Diagnostics,
+ input: &Input,
+) {
+ puffin::profile_function!();
+ ui.heading("Config");
+ ui.add(egui::Slider::new(&mut config.brush_radius, 1..=100).text("Brush radius"));
+
+ let material = config.brush_material.def();
+
+ // material combobox
+ egui::ComboBox::from_label("Select a material")
+ .selected_text(format!(
+ "Material: [{}, d={}]",
+ material.name, material.density,
+ ))
+ .icon(move |ui, rect, _, _| {
+ ui.painter().add(egui::Shape::Circle(CircleShape {
+ center: rect.center(),
+ radius: rect.width() / 2.5,
+ stroke: Stroke::NONE,
+ fill: Color32::from_rgb(material.color.0, material.color.1, material.color.2),
+ }));
+ })
+ .show_ui(ui, |ui| {
+ for material_id in MaterialId::ALL {
+ ui.selectable_value(
+ &mut config.brush_material,
+ material_id,
+ material_id.def().name,
+ );
+ }
+ });
+
+ ui.checkbox(&mut config.use_threading, "Use multithreading");
+ ui.label(format!("Real FPS: {}", diagnostics.fps));
+ ui.heading("Camera");
+ ui.add(egui::Slider::new(&mut camera.zoom, 0.0..=10.0).text("Zoom"));
+ ui.heading("Input");
+
+ input.last_mouse_pos_on_screen.map(|p| {
+ ui.label(format!(
+ "Mouse: x,y=({x}, {y}), lmb_pressed={lmb}",
+ x = p.0,
+ y = p.1,
+ lmb = input.is_lmb_pressed
+ ))
+ });
+
+ input
+ .last_mouse_pos_on_board
+ .map(|p| ui.label(format!("Mouse (board): x,y=({x}, {y})", x = p.0, y = p.1,)));
+
+ input
+ .last_mouse_pos_on_board
+ .map(|p| ui.label(format!("Mouse (chunk): x,y=({x}, {y})", x = p.0, y = p.1,)));
+}