diff --git a/egui-inspect-derive/src/inspect_macro/args/mod.rs b/egui-inspect-derive/src/inspect_macro/args/mod.rs index 8805dee0..152baa03 100644 --- a/egui-inspect-derive/src/inspect_macro/args/mod.rs +++ b/egui-inspect-derive/src/inspect_macro/args/mod.rs @@ -21,7 +21,7 @@ pub struct InspectStructArgs { pub ident: syn::Ident, } -// We support multiple distinct inspect annotations (i.e. inspect_slider, inspect_text) +// We support multiple distinct debug_inspect annotations (i.e. inspect_slider, inspect_text) // Each distinct type will have a struct for capturing the metadata. These metadata structs // must implement this trait pub trait InspectFieldArgs { diff --git a/egui-inspect-derive/src/inspect_macro/mod.rs b/egui-inspect-derive/src/inspect_macro/mod.rs index 7fc677ef..1b871785 100644 --- a/egui-inspect-derive/src/inspect_macro/mod.rs +++ b/egui-inspect-derive/src/inspect_macro/mod.rs @@ -113,7 +113,7 @@ fn handle_inspect_type< ) { if parsed_field.is_some() { panic!( - "Too many inspect attributes on a single member {:?}", + "Too many debug_inspect attributes on a single member {:?}", f.ident ); } diff --git a/egui-inspect/src/impls/mod.rs b/egui-inspect/src/impls/mod.rs index ae8d21f8..1a9aaf18 100644 --- a/egui-inspect/src/impls/mod.rs +++ b/egui-inspect/src/impls/mod.rs @@ -26,7 +26,7 @@ pub use option::OptionDefault; /// So, not all elements will necessarily be used/respected. Use the non-default traits for typesafe /// changes. /// -/// Marking a struct element with something like `#[inspect(min_value = 5.0, max_value = 53.0)]` +/// Marking a struct element with something like `#[debug_inspect(min_value = 5.0, max_value = 53.0)]` /// will make the widget for that member default to those values. #[derive(Clone, Default, Debug)] pub struct InspectArgs { diff --git a/native_app/src/gui/inspect/inspect_debug.rs b/native_app/src/gui/debug_inspect.rs similarity index 83% rename from native_app/src/gui/inspect/inspect_debug.rs rename to native_app/src/gui/debug_inspect.rs index ae9da6b0..4647f1b1 100644 --- a/native_app/src/gui/inspect/inspect_debug.rs +++ b/native_app/src/gui/debug_inspect.rs @@ -1,6 +1,6 @@ -use crate::newgui::follow::FollowEntity; -use crate::uiworld::UiWorld; use egui::Ui; +use egui::{Context, Window}; + use egui_inspect::{Inspect, InspectArgs}; use simulation::economy::Market; use simulation::transportation::Location; @@ -9,8 +9,38 @@ use simulation::{ WagonEnt, }; +use crate::gui::windows::debug::DebugState; +use crate::newgui::follow::FollowEntity; +use crate::newgui::InspectedEntity; +use crate::uiworld::UiWorld; + +pub fn debug_inspector(ui: &Context, uiworld: &UiWorld, sim: &Simulation) { + profiling::scope!("hud::inspector"); + let e = unwrap_or!(uiworld.read::().e, return); + + let force_debug_inspect = uiworld.read::().debug_inspector; + + let mut is_open = true; + if force_debug_inspect { + Window::new("Inspect") + .default_size([400.0, 500.0]) + .default_pos([30.0, 160.0]) + .resizable(true) + .open(&mut is_open) + .show(ui, |ui| { + let mut ins = InspectRenderer { entity: e }; + ins.render(uiworld, sim, ui); + uiworld.write::().e = Some(ins.entity); + }); + } + + if !is_open { + uiworld.write::().e = None; + } +} + /// Inspect window -/// Allows to inspect an entity +/// Allows to debug_inspect an entity pub struct InspectRenderer { pub entity: AnyEntity, } @@ -55,7 +85,7 @@ impl InspectRenderer { for (hid, h) in sim.world().humans.iter() { if h.location == Location::Vehicle(id) && ui - .small_button(&*format!("inspect inside vehicle: {hid:?}")) + .small_button(&*format!("debug_inspect inside vehicle: {hid:?}")) .clicked() { self.entity = hid.into(); diff --git a/native_app/src/gui/hud.rs b/native_app/src/gui/hud.rs index 481aea5f..278dce03 100644 --- a/native_app/src/gui/hud.rs +++ b/native_app/src/gui/hud.rs @@ -5,7 +5,7 @@ use simulation::economy::Government; use simulation::Simulation; use crate::gui::chat::chat; -use crate::gui::inspect::inspector; +use crate::gui::debug_inspect::debug_inspector; use crate::newgui::{ErrorTooltip, GuiState, PotentialCommands}; use crate::uiworld::UiWorld; @@ -16,7 +16,7 @@ pub fn render_oldgui(ui: &Context, uiworld: &UiWorld, sim: &Simulation) { return; } - inspector(ui, uiworld, sim); + debug_inspector(ui, uiworld, sim); chat(ui, uiworld, sim); diff --git a/native_app/src/gui/inspect/mod.rs b/native_app/src/gui/inspect/mod.rs deleted file mode 100644 index 148619c3..00000000 --- a/native_app/src/gui/inspect/mod.rs +++ /dev/null @@ -1,35 +0,0 @@ -use egui::{Context, Window}; - -use inspect_debug::InspectRenderer; -use simulation::Simulation; - -use crate::gui::windows::debug::DebugState; -use crate::newgui::InspectedEntity; -use crate::uiworld::UiWorld; - -mod inspect_debug; - -pub fn inspector(ui: &Context, uiworld: &UiWorld, sim: &Simulation) { - profiling::scope!("hud::inspector"); - let e = unwrap_or!(uiworld.read::().e, return); - - let force_debug_inspect = uiworld.read::().debug_inspector; - - let mut is_open = true; - if force_debug_inspect { - Window::new("Inspect") - .default_size([400.0, 500.0]) - .default_pos([30.0, 160.0]) - .resizable(true) - .open(&mut is_open) - .show(ui, |ui| { - let mut ins = InspectRenderer { entity: e }; - ins.render(uiworld, sim, ui); - uiworld.write::().e = Some(ins.entity); - }); - } - - if !is_open { - uiworld.write::().e = None; - } -} diff --git a/native_app/src/gui/mod.rs b/native_app/src/gui/mod.rs index b0661a42..acbe9212 100644 --- a/native_app/src/gui/mod.rs +++ b/native_app/src/gui/mod.rs @@ -1,6 +1,6 @@ pub mod chat; +pub mod debug_inspect; pub mod hud; -pub mod inspect; pub mod windows; pub use hud::*;