Skip to content

Commit

Permalink
Indicate the selected material
Browse files Browse the repository at this point in the history
  • Loading branch information
patowen committed May 5, 2024
1 parent a5b0597 commit 8bba2b5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
19 changes: 15 additions & 4 deletions client/src/graphics/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use ash::vk;
use common::traversal;
use lahar::Staged;
use metrics::histogram;
use yakui::Color;

use super::{fog, voxels, Base, Fog, Frustum, GltfScene, Meshes, Voxels};
use crate::{Asset, Config, Loader, Sim};
Expand Down Expand Up @@ -302,10 +303,20 @@ impl Draw {
));

self.yak.start();
yakui::text(96.0, "Hello world!");
yakui::align(yakui::Alignment::CENTER, || {
yakui::colored_box(yakui::Color::BLACK.with_alpha(0.9), [5.0, 5.0]);
});
if let Some(sim) = sim.as_ref() {
// Cursor
yakui::align(yakui::Alignment::CENTER, || {
yakui::colored_box(yakui::Color::BLACK.with_alpha(0.9), [5.0, 5.0]);
});

yakui::align(yakui::Alignment::TOP_LEFT, || {
yakui::pad(yakui::widgets::Pad::all(8.0), || {
yakui::colored_box_container(Color::BLACK.with_alpha(0.7), || {
yakui::label(format!("Selected material: {:?}", sim.selected_material()));
});
});
});
}
self.yak.finish();

let paint = self.yak.paint();
Expand Down
4 changes: 4 additions & 0 deletions client/src/sim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 8bba2b5

Please sign in to comment.