diff --git a/client/src/graphics/gui.rs b/client/src/graphics/gui.rs index e0fc2351..14353cc6 100644 --- a/client/src/graphics/gui.rs +++ b/client/src/graphics/gui.rs @@ -1,4 +1,8 @@ -use yakui::{align, colored_box, Alignment, Color}; +use yakui::{ + align, colored_box, colored_box_container, label, pad, widgets::Pad, Alignment, Color, +}; + +use crate::Sim; pub struct GuiState { show_gui: bool, @@ -16,7 +20,7 @@ impl GuiState { /// Prepare the GUI for rendering. This should be called between /// Yakui::start and Yakui::finish. - pub fn run(&self) { + pub fn run(&self, sim: &Sim) { if !self.show_gui { return; } @@ -24,5 +28,13 @@ impl GuiState { align(Alignment::CENTER, || { colored_box(Color::BLACK.with_alpha(0.9), [5.0, 5.0]); }); + + align(Alignment::TOP_LEFT, || { + pad(Pad::all(8.0), || { + colored_box_container(Color::BLACK.with_alpha(0.7), || { + label(format!("Selected material: {:?}", sim.selected_material())); + }); + }); + }); } } diff --git a/client/src/graphics/window.rs b/client/src/graphics/window.rs index cf27dba0..e4302df5 100644 --- a/client/src/graphics/window.rs +++ b/client/src/graphics/window.rs @@ -366,7 +366,9 @@ impl Window { [extent.width as f32, extent.height as f32].into(), )); self.yak.start(); - self.gui_state.run(); + if let Some(sim) = self.sim.as_ref() { + self.gui_state.run(sim); + } self.yak.finish(); // Render the frame draw.draw( diff --git a/client/src/sim.rs b/client/src/sim.rs index 8abfe08c..9f59582f 100644 --- a/client/src/sim.rs +++ b/client/src/sim.rs @@ -161,6 +161,10 @@ impl Sim { self.selected_material = *MATERIAL_PALETTE.get(idx).unwrap_or(&MATERIAL_PALETTE[0]); } + pub fn selected_material(&self) -> Material { + self.selected_material + } + pub fn set_break_block_pressed_true(&mut self) { self.break_block_pressed = true; }