mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Tidied up egui windows
This commit is contained in:
parent
0b10752a7d
commit
cc19e70ae6
@ -113,27 +113,30 @@ impl SelectedEntityInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct EguiInnerState {
|
pub struct EguiInnerState {
|
||||||
read_ecs: bool,
|
|
||||||
selected_entity_info: Option<SelectedEntityInfo>,
|
selected_entity_info: Option<SelectedEntityInfo>,
|
||||||
max_entity_distance: f32,
|
max_entity_distance: f32,
|
||||||
selected_entity_cylinder_height: f32,
|
selected_entity_cylinder_height: f32,
|
||||||
frame_times: Vec<f32>,
|
frame_times: Vec<f32>,
|
||||||
show_inspection_ui: bool,
|
windows: EguiWindows,
|
||||||
show_settings_ui: bool,
|
}
|
||||||
show_memory_ui: bool,
|
|
||||||
|
#[derive(Default)]
|
||||||
|
struct EguiWindows {
|
||||||
|
egui_inspection: bool,
|
||||||
|
egui_settings: bool,
|
||||||
|
egui_memory: bool,
|
||||||
|
frame_time: bool,
|
||||||
|
ecs_entities: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for EguiInnerState {
|
impl Default for EguiInnerState {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
read_ecs: false,
|
|
||||||
selected_entity_info: None,
|
selected_entity_info: None,
|
||||||
max_entity_distance: 100000.0,
|
max_entity_distance: 100000.0,
|
||||||
selected_entity_cylinder_height: 10.0,
|
selected_entity_cylinder_height: 10.0,
|
||||||
frame_times: Vec::new(),
|
frame_times: Vec::new(),
|
||||||
show_inspection_ui: false,
|
windows: Default::default(),
|
||||||
show_settings_ui: false,
|
|
||||||
show_memory_ui: false,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -189,67 +192,72 @@ pub fn maintain_egui_inner(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
egui::Window::new("Test Window")
|
egui::Window::new("Debug Control")
|
||||||
.default_width(200.0)
|
.default_width(200.0)
|
||||||
.default_height(200.0)
|
.default_height(200.0)
|
||||||
.show(&platform.context(), |ui| {
|
.show(&platform.context(), |ui| {
|
||||||
ui.heading("Debug UI");
|
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.label(format!(
|
ui.label(format!(
|
||||||
"Ping: {:.1}ms",
|
"Ping: {:.1}ms",
|
||||||
debug_info.as_ref().map_or(0.0, |x| x.ping_ms)
|
debug_info.as_ref().map_or(0.0, |x| x.ping_ms)
|
||||||
));
|
));
|
||||||
});
|
});
|
||||||
if ui.button("Enable ECS reading").clicked() {
|
ui.group(|ui| {
|
||||||
egui_state.read_ecs = true;
|
ui.vertical(|ui| {
|
||||||
}
|
ui.checkbox(&mut egui_state.windows.ecs_entities, "ECS Entities");
|
||||||
|
ui.checkbox(&mut egui_state.windows.frame_time, "Frame Time");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
ui.group(|ui| {
|
ui.group(|ui| {
|
||||||
ui.vertical(|ui| {
|
ui.vertical(|ui| {
|
||||||
ui.label("Show EGUI Windows");
|
ui.label("Show EGUI Windows");
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.checkbox(&mut egui_state.show_inspection_ui, "🔍 Inspection");
|
ui.checkbox(&mut egui_state.windows.egui_inspection, "🔍 Inspection");
|
||||||
ui.checkbox(&mut egui_state.show_settings_ui, "🔍 Settings");
|
ui.checkbox(&mut egui_state.windows.egui_settings, "🔍 Settings");
|
||||||
ui.checkbox(&mut egui_state.show_memory_ui, "📝 Memory");
|
ui.checkbox(&mut egui_state.windows.egui_memory, "📝 Memory");
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
Window::new("🔧 Settings")
|
Window::new("🔧 Settings")
|
||||||
.open(&mut egui_state.show_settings_ui)
|
.open(&mut egui_state.windows.egui_settings)
|
||||||
.scroll(true)
|
.scroll(true)
|
||||||
.show(ctx, |ui| {
|
.show(ctx, |ui| {
|
||||||
ctx.settings_ui(ui);
|
ctx.settings_ui(ui);
|
||||||
});
|
});
|
||||||
Window::new("🔍 Inspection")
|
Window::new("🔍 Inspection")
|
||||||
.open(&mut egui_state.show_inspection_ui)
|
.open(&mut egui_state.windows.egui_inspection)
|
||||||
.scroll(true)
|
.scroll(true)
|
||||||
.show(ctx, |ui| {
|
.show(ctx, |ui| {
|
||||||
ctx.inspection_ui(ui);
|
ctx.inspection_ui(ui);
|
||||||
});
|
});
|
||||||
|
|
||||||
Window::new("📝 Memory")
|
Window::new("📝 Memory")
|
||||||
.open(&mut egui_state.show_memory_ui)
|
.open(&mut egui_state.windows.egui_memory)
|
||||||
.resizable(false)
|
.resizable(false)
|
||||||
.show(ctx, |ui| {
|
.show(ctx, |ui| {
|
||||||
ctx.memory_ui(ui);
|
ctx.memory_ui(ui);
|
||||||
});
|
});
|
||||||
|
|
||||||
Window::new("Frame Time")
|
if egui_state.windows.frame_time {
|
||||||
.default_width(200.0)
|
Window::new("Frame Time")
|
||||||
.default_height(200.0)
|
.default_width(200.0)
|
||||||
.show(ctx, |ui| {
|
.default_height(200.0)
|
||||||
let plot = Plot::default().curve(Curve::from_values_iter(
|
.show(ctx, |ui| {
|
||||||
egui_state
|
let plot = Plot::default().curve(Curve::from_values_iter(
|
||||||
.frame_times
|
egui_state
|
||||||
.iter()
|
.frame_times
|
||||||
.enumerate()
|
.iter()
|
||||||
.map(|(i, x)| Value::new(i as f64, *x)),
|
.enumerate()
|
||||||
));
|
.map(|(i, x)| Value::new(i as f64, *x)),
|
||||||
ui.add(plot);
|
));
|
||||||
});
|
ui.add(plot);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if egui_state.read_ecs {
|
if egui_state.windows.ecs_entities {
|
||||||
let ecs = client.state().ecs();
|
let ecs = client.state().ecs();
|
||||||
|
|
||||||
let positions = client.state().ecs().read_storage::<comp::Pos>();
|
let positions = client.state().ecs().read_storage::<comp::Pos>();
|
||||||
@ -276,9 +284,6 @@ pub fn maintain_egui_inner(
|
|||||||
|
|
||||||
let scroll_area = ScrollArea::from_max_height(800.0);
|
let scroll_area = ScrollArea::from_max_height(800.0);
|
||||||
let (_current_scroll, _max_scroll) = scroll_area.show(ui, |ui| {
|
let (_current_scroll, _max_scroll) = scroll_area.show(ui, |ui| {
|
||||||
// if scroll_top {
|
|
||||||
// ui.scroll_to_cursor(Align::TOP);
|
|
||||||
// }
|
|
||||||
Grid::new("entities_grid")
|
Grid::new("entities_grid")
|
||||||
.spacing([40.0, 4.0])
|
.spacing([40.0, 4.0])
|
||||||
.max_col_width(300.0)
|
.max_col_width(300.0)
|
||||||
@ -310,11 +315,6 @@ pub fn maintain_egui_inner(
|
|||||||
< max_entity_distance
|
< max_entity_distance
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
// .sorted_by(|(_, _, pos, _, _, _)| {
|
|
||||||
// client_pos.map_or(Ordering::Less, |client_pos| {
|
|
||||||
// pos.map_or(|| 0.0, |x| x.distance_squared(client_pos.0))
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
{
|
{
|
||||||
if ui.button("View").clicked() {
|
if ui.button("View").clicked() {
|
||||||
previous_selected_entity =
|
previous_selected_entity =
|
||||||
@ -483,18 +483,6 @@ fn selected_entity_window(
|
|||||||
.default_height(200.0)
|
.default_height(200.0)
|
||||||
.show(&platform.context(), |ui| {
|
.show(&platform.context(), |ui| {
|
||||||
ui.vertical(|ui| {
|
ui.vertical(|ui| {
|
||||||
|
|
||||||
// let n = 128;
|
|
||||||
// let curve = egui::plot::Curve::from_values_iter((0..=n).map(|i| {
|
|
||||||
// use std::f64::consts::TAU;
|
|
||||||
// let x = egui::remap(i as f64, 0.0..=(n as f64), -TAU..=TAU);
|
|
||||||
// egui::plot::Value::new(x, x.sin())
|
|
||||||
// }));
|
|
||||||
// egui::plot::Plot::default()
|
|
||||||
// .curve(curve)
|
|
||||||
// .height(32.0)
|
|
||||||
// .data_aspect(1.0);
|
|
||||||
|
|
||||||
CollapsingHeader::new("General").default_open(true).show(ui, |ui| {
|
CollapsingHeader::new("General").default_open(true).show(ui, |ui| {
|
||||||
Grid::new("selected_entity_general_grid")
|
Grid::new("selected_entity_general_grid")
|
||||||
.spacing([40.0, 4.0])
|
.spacing([40.0, 4.0])
|
||||||
@ -508,7 +496,6 @@ fn selected_entity_window(
|
|||||||
two_col_row(ui, "Scale", scale.map_or("-".to_owned(), |x| format!("{:?}", x)));
|
two_col_row(ui, "Scale", scale.map_or("-".to_owned(), |x| format!("{:?}", x)));
|
||||||
two_col_row(ui, "Mass", mass.map_or("-".to_owned(), |x| format!("{:.1}", x.0)));
|
two_col_row(ui, "Mass", mass.map_or("-".to_owned(), |x| format!("{:.1}", x.0)));
|
||||||
two_col_row(ui, "Density", density.map_or("-".to_owned(), |x| format!("{:.1}", x.0)));
|
two_col_row(ui, "Density", density.map_or("-".to_owned(), |x| format!("{:.1}", x.0)));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -654,7 +641,6 @@ fn selected_entity_window(
|
|||||||
_ => "None".to_owned() });
|
_ => "None".to_owned() });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -47,9 +47,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
use common::clock::Clock;
|
use common::clock::Clock;
|
||||||
use common_base::span;
|
use common_base::span;
|
||||||
use egui_winit_platform::Platform;
|
|
||||||
use i18n::LocalizationHandle;
|
use i18n::LocalizationHandle;
|
||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
/// A type used to store state that is shared between all play states.
|
/// A type used to store state that is shared between all play states.
|
||||||
pub struct GlobalState {
|
pub struct GlobalState {
|
||||||
|
@ -6,11 +6,9 @@ use super::char_selection::CharSelectionState;
|
|||||||
#[cfg(feature = "singleplayer")]
|
#[cfg(feature = "singleplayer")]
|
||||||
use crate::singleplayer::Singleplayer;
|
use crate::singleplayer::Singleplayer;
|
||||||
use crate::{
|
use crate::{
|
||||||
i18n::LocalizationHandle, render::Renderer, settings::Settings, window::Event, Direction,
|
i18n::LocalizationHandle, window::Event, Direction, GlobalState, PlayState, PlayStateResult,
|
||||||
GlobalState, PlayState, PlayStateResult,
|
|
||||||
};
|
};
|
||||||
#[cfg(feature = "singleplayer")]
|
#[cfg(feature = "singleplayer")]
|
||||||
use client::addr::ConnectionArgs;
|
|
||||||
use client::{
|
use client::{
|
||||||
addr::ConnectionArgs,
|
addr::ConnectionArgs,
|
||||||
error::{InitProtocolError, NetworkConnectError, NetworkError},
|
error::{InitProtocolError, NetworkConnectError, NetworkError},
|
||||||
|
@ -176,6 +176,7 @@ fn handle_main_events_cleared(
|
|||||||
if !exit {
|
if !exit {
|
||||||
// Wait for the next tick.
|
// Wait for the next tick.
|
||||||
span!(guard, "Main thread sleep");
|
span!(guard, "Main thread sleep");
|
||||||
|
|
||||||
global_state.clock.set_target_dt(Duration::from_secs_f64(
|
global_state.clock.set_target_dt(Duration::from_secs_f64(
|
||||||
1.0 / get_fps(global_state.settings.graphics.max_fps) as f64,
|
1.0 / get_fps(global_state.settings.graphics.max_fps) as f64,
|
||||||
));
|
));
|
||||||
|
Loading…
Reference in New Issue
Block a user