Skip to content

Commit

Permalink
downgrade inspect to debug_inspect
Browse files Browse the repository at this point in the history
  • Loading branch information
Uriopass committed Feb 14, 2024
1 parent 097da22 commit 625d176
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 45 deletions.
2 changes: 1 addition & 1 deletion egui-inspect-derive/src/inspect_macro/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion egui-inspect-derive/src/inspect_macro/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
Expand Down
2 changes: 1 addition & 1 deletion egui-inspect/src/impls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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::<InspectedEntity>().e, return);

let force_debug_inspect = uiworld.read::<DebugState>().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::<InspectedEntity>().e = Some(ins.entity);
});
}

if !is_open {
uiworld.write::<InspectedEntity>().e = None;
}
}

/// Inspect window
/// Allows to inspect an entity
/// Allows to debug_inspect an entity
pub struct InspectRenderer {
pub entity: AnyEntity,
}
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions native_app/src/gui/hud.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);

Expand Down
35 changes: 0 additions & 35 deletions native_app/src/gui/inspect/mod.rs

This file was deleted.

2 changes: 1 addition & 1 deletion native_app/src/gui/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub mod chat;
pub mod debug_inspect;
pub mod hud;
pub mod inspect;
pub mod windows;

pub use hud::*;

0 comments on commit 625d176

Please sign in to comment.