summaryrefslogtreecommitdiff
path: root/src/renderer/ui.rs
diff options
context:
space:
mode:
authorKai Stevenson <kai@kaistevenson.com>2026-08-15 22:46:53 -0700
committerKai Stevenson <kai@kaistevenson.com>2026-08-15 22:46:53 -0700
commitd7eccba2055cd7784a0db6d9ee8692a4f3510931 (patch)
tree37f4c19781c788fa2af1ee4eeb7195f49a6d2d7a /src/renderer/ui.rs
parent05135beb87bbf0edace544b80ba40e327d9a89ac (diff)
fire, optimize viewport rendering
Diffstat (limited to 'src/renderer/ui.rs')
-rw-r--r--src/renderer/ui.rs35
1 files changed, 26 insertions, 9 deletions
diff --git a/src/renderer/ui.rs b/src/renderer/ui.rs
index 87ab878..b4e6f74 100644
--- a/src/renderer/ui.rs
+++ b/src/renderer/ui.rs
@@ -1,6 +1,9 @@
use egui::{Color32, Stroke, Ui, epaint::CircleShape};
-use crate::{Camera, Config, Diagnostics, Input, sim::materials::MaterialId};
+use crate::{
+ Camera, Config, Diagnostics, Input,
+ sim::{materials::MaterialId, world::World},
+};
pub fn draw_egui<'a>(
ui: &mut Ui,
@@ -8,6 +11,7 @@ pub fn draw_egui<'a>(
camera: &mut Camera,
diagnostics: &Diagnostics,
input: &Input,
+ world: &World,
) {
puffin::profile_function!();
ui.heading("Config");
@@ -24,7 +28,7 @@ pub fn draw_egui<'a>(
.icon(move |ui, rect, _, _| {
ui.painter().add(egui::Shape::Circle(CircleShape {
center: rect.center(),
- radius: rect.width() / 2.5,
+ radius: rect.height() / 2.0,
stroke: Stroke::NONE,
fill: Color32::from_rgb(material.color.0, material.color.1, material.color.2),
}));
@@ -54,11 +58,24 @@ pub fn draw_egui<'a>(
))
});
- 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,)));
+ if let Some((x, y)) = input.last_mouse_pos_on_board {
+ ui.heading("Entity");
+ ui.label(format!("x,y=({x}, {y})"));
+ if let Some(cell) = world.get_cell_from_game_position(x, y) {
+ let material = cell.material.def();
+ let cell_label = ui.label(
+ egui::RichText::new(format!("Cell: {}", material.name)).color(Color32::LIGHT_BLUE),
+ );
+ ui.painter().add(egui::Shape::Circle(CircleShape {
+ center: cell_label.rect.right_center() + egui::vec2(10.0, 0.0),
+ radius: cell_label.rect.height() / 2.5,
+ stroke: Stroke::NONE,
+ fill: Color32::from_rgb(material.color.0, material.color.1, material.color.2),
+ }));
+ ui.label(
+ egui::RichText::new(format!("Flags: {:b}", cell.flags)).color(Color32::YELLOW),
+ );
+ ui.label(egui::RichText::new(format!("Data: {:b}", cell.data)).color(Color32::RED));
+ }
+ }
}