mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Updated egui to 0.12, fixed window closing
This commit is contained in:
parent
da2fd8c7bf
commit
0db5d965a6
25
Cargo.lock
generated
25
Cargo.lock
generated
@ -1442,18 +1442,17 @@ checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
|
||||
|
||||
[[package]]
|
||||
name = "egui"
|
||||
version = "0.11.0"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2d7d6535c3ecdc8627a72c1c52d052d66cd9f71c238428690cc46bef9d1f2bce"
|
||||
checksum = "788148861d80b87d28d64440a3d31cae190e50ccc3ea585597466d38428365d7"
|
||||
dependencies = [
|
||||
"epaint",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "egui_wgpu_backend"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f6aa6fec3ad8de51b5d7e2a11eb6cb0fd3533a7b817e5af54eda8e7fe53729bd"
|
||||
version = "0.8.0"
|
||||
source = "git+https://github.com/hasenbanck/egui_wgpu_backend.git?rev=63a002c6a9b6c016e45806dd065864431caab621#63a002c6a9b6c016e45806dd065864431caab621"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"epi",
|
||||
@ -1462,9 +1461,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "egui_winit_platform"
|
||||
version = "0.6.0"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "abb2766d3864d7391e34b9aa78caaa01c162baf1481523a371914e3f42144d84"
|
||||
checksum = "69ff13f463b60b77361ddf2125e6cbfe410fc66bf4004a8e720508ce9027a6b6"
|
||||
dependencies = [
|
||||
"egui",
|
||||
"winit",
|
||||
@ -1478,9 +1477,9 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
|
||||
|
||||
[[package]]
|
||||
name = "emath"
|
||||
version = "0.11.0"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4ed72c14666517e5c0198490864adea871081abe4f5523af8c3f4f56595142e"
|
||||
checksum = "3e73d6c8c70eadb71756fbbc3c303ab25e163b46b656886dd250de5636efea12"
|
||||
|
||||
[[package]]
|
||||
name = "encoding_rs"
|
||||
@ -1540,9 +1539,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "epaint"
|
||||
version = "0.11.0"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a19eff631454edbe5abe4693be00be0c1ea9832d727dc385c16841caa2d0162"
|
||||
checksum = "80e2db640801230bdda80629bc3a063927a462f5eaf38a98da676954e78ccb99"
|
||||
dependencies = [
|
||||
"ahash 0.7.2",
|
||||
"atomic_refcell",
|
||||
@ -1553,9 +1552,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "epi"
|
||||
version = "0.11.0"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c2242aee03bc64fd16d58866e18c0f210004b95963bef30820747d18b9f5d627"
|
||||
checksum = "59c4f6cbede1fc8f836384f85295a59199a4825940abcc3a8a29cfe2e3c37583"
|
||||
dependencies = [
|
||||
"egui",
|
||||
]
|
||||
|
@ -122,7 +122,6 @@ winit = { git = "https://gitlab.com/veloren/winit.git", branch = "macos-test-spi
|
||||
vek = { git = "https://gitlab.com/veloren/vek.git", branch = "fix_intrinsics2" }
|
||||
# patch wgpu so we can use wgpu-profiler crate
|
||||
wgpu = { git = "https://github.com/gfx-rs/wgpu-rs.git", rev = "7486bdad64bb5d17b709ecccb41e063469efff88" }
|
||||
|
||||
# # use the latest fixes in naga (remove when updates trickle down to wgpu-rs)
|
||||
# naga = { git = "https://github.com/gfx-rs/naga.git", rev = "3a0f0144112ff621dd7f731bf455adf6cab19164" }
|
||||
# # use the latest fixes in gfx (remove when updates trickle down to wgpu-rs)
|
||||
|
@ -65,10 +65,10 @@ glyph_brush = "0.7.0"
|
||||
keyboard-keynames = { git = "https://gitlab.com/Frinksy/keyboard-keynames.git", rev = "a97ae509cdb9dc70cf1bf0af762d2d1d3a0d6e0c" }
|
||||
|
||||
# EGUI
|
||||
egui = {version = "0.11", optional = true }
|
||||
egui_wgpu_backend = {version = "0.7", optional = true }
|
||||
egui = {version = "0.12", optional = true }
|
||||
egui_wgpu_backend = {git = "https://github.com/hasenbanck/egui_wgpu_backend.git", rev = "63a002c6a9b6c016e45806dd065864431caab621", optional = true }
|
||||
#egui_wgpu_backend = { path = "../../egui_wgpu_backend" }
|
||||
egui_winit_platform = {version = "0.6", optional = true }
|
||||
egui_winit_platform = {version = "0.7", optional = true }
|
||||
#egui_winit_platform = { path = "../../egui_winit_platform" }
|
||||
|
||||
# ECS
|
||||
|
@ -11,8 +11,8 @@ be-dyn-lib = []
|
||||
[dependencies]
|
||||
client = {package = "veloren-client", path = "../../client"}
|
||||
common = {package = "veloren-common", path = "../../common"}
|
||||
egui = "0.11"
|
||||
egui_winit_platform = "0.6"
|
||||
egui = "0.12"
|
||||
egui_winit_platform = "0.7"
|
||||
voxygen-dynlib = {package = "veloren-voxygen-dynlib", path = "../dynlib"}
|
||||
|
||||
# Hot Reloading
|
||||
|
@ -46,6 +46,7 @@ const MAINTAIN_EGUI_FN: &[u8] = b"maintain_egui_inner\0";
|
||||
pub fn maintain(
|
||||
platform: &mut Platform,
|
||||
egui_state: &mut EguiInnerState,
|
||||
egui_windows: &mut EguiWindows,
|
||||
client: &Client,
|
||||
debug_info: &Option<DebugInfo>,
|
||||
added_cylinder_shape_id: Option<u64>,
|
||||
@ -55,6 +56,7 @@ pub fn maintain(
|
||||
maintain_egui_inner(
|
||||
platform,
|
||||
egui_state,
|
||||
egui_windows,
|
||||
client,
|
||||
debug_info,
|
||||
added_cylinder_shape_id,
|
||||
@ -71,6 +73,7 @@ pub fn maintain(
|
||||
fn(
|
||||
&mut Platform,
|
||||
&mut EguiInnerState,
|
||||
&mut EguiWindows,
|
||||
&Client,
|
||||
&Option<DebugInfo>,
|
||||
Option<u64>,
|
||||
@ -89,6 +92,7 @@ pub fn maintain(
|
||||
maintain_fn(
|
||||
platform,
|
||||
egui_state,
|
||||
egui_windows,
|
||||
client,
|
||||
debug_info,
|
||||
added_cylinder_shape_id,
|
||||
@ -117,11 +121,10 @@ pub struct EguiInnerState {
|
||||
max_entity_distance: f32,
|
||||
selected_entity_cylinder_height: f32,
|
||||
frame_times: Vec<f32>,
|
||||
windows: EguiWindows,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct EguiWindows {
|
||||
#[derive(Clone, Default)]
|
||||
pub struct EguiWindows {
|
||||
egui_inspection: bool,
|
||||
egui_settings: bool,
|
||||
egui_memory: bool,
|
||||
@ -136,7 +139,6 @@ impl Default for EguiInnerState {
|
||||
max_entity_distance: 100000.0,
|
||||
selected_entity_cylinder_height: 10.0,
|
||||
frame_times: Vec::new(),
|
||||
windows: Default::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -163,6 +165,7 @@ pub struct EguiActions {
|
||||
pub fn maintain_egui_inner(
|
||||
platform: &mut Platform,
|
||||
egui_state: &mut EguiInnerState,
|
||||
egui_windows: &mut EguiWindows,
|
||||
client: &Client,
|
||||
debug_info: &Option<DebugInfo>,
|
||||
added_cylinder_shape_id: Option<u64>,
|
||||
@ -204,8 +207,8 @@ pub fn maintain_egui_inner(
|
||||
});
|
||||
ui.group(|ui| {
|
||||
ui.vertical(|ui| {
|
||||
ui.checkbox(&mut egui_state.windows.ecs_entities, "ECS Entities");
|
||||
ui.checkbox(&mut egui_state.windows.frame_time, "Frame Time");
|
||||
ui.checkbox(&mut egui_windows.ecs_entities, "ECS Entities");
|
||||
ui.checkbox(&mut egui_windows.frame_time, "Frame Time");
|
||||
});
|
||||
});
|
||||
|
||||
@ -213,57 +216,57 @@ pub fn maintain_egui_inner(
|
||||
ui.vertical(|ui| {
|
||||
ui.label("Show EGUI Windows");
|
||||
ui.horizontal(|ui| {
|
||||
ui.checkbox(&mut egui_state.windows.egui_inspection, "🔍 Inspection");
|
||||
ui.checkbox(&mut egui_state.windows.egui_settings, "🔍 Settings");
|
||||
ui.checkbox(&mut egui_state.windows.egui_memory, "📝 Memory");
|
||||
ui.checkbox(&mut egui_windows.egui_inspection, "🔍 Inspection");
|
||||
ui.checkbox(&mut egui_windows.egui_settings, "🔍 Settings");
|
||||
ui.checkbox(&mut egui_windows.egui_memory, "📝 Memory");
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
Window::new("🔧 Settings")
|
||||
.open(&mut egui_state.windows.egui_settings)
|
||||
.open(&mut egui_windows.egui_settings)
|
||||
.scroll(true)
|
||||
.show(ctx, |ui| {
|
||||
ctx.settings_ui(ui);
|
||||
});
|
||||
Window::new("🔍 Inspection")
|
||||
.open(&mut egui_state.windows.egui_inspection)
|
||||
.open(&mut egui_windows.egui_inspection)
|
||||
.scroll(true)
|
||||
.show(ctx, |ui| {
|
||||
ctx.inspection_ui(ui);
|
||||
});
|
||||
|
||||
Window::new("📝 Memory")
|
||||
.open(&mut egui_state.windows.egui_memory)
|
||||
.open(&mut egui_windows.egui_memory)
|
||||
.resizable(false)
|
||||
.show(ctx, |ui| {
|
||||
ctx.memory_ui(ui);
|
||||
});
|
||||
|
||||
if egui_state.windows.frame_time {
|
||||
Window::new("Frame Time")
|
||||
.default_width(200.0)
|
||||
.default_height(200.0)
|
||||
.show(ctx, |ui| {
|
||||
let plot = Plot::default().curve(Curve::from_values_iter(
|
||||
egui_state
|
||||
.frame_times
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, x)| Value::new(i as f64, *x)),
|
||||
));
|
||||
ui.add(plot);
|
||||
});
|
||||
}
|
||||
Window::new("Frame Time")
|
||||
.open(&mut egui_windows.frame_time)
|
||||
.default_width(200.0)
|
||||
.default_height(200.0)
|
||||
.show(ctx, |ui| {
|
||||
let plot = Plot::new("Frame Time").curve(Curve::from_values_iter(
|
||||
egui_state
|
||||
.frame_times
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, x)| Value::new(i as f64, *x)),
|
||||
));
|
||||
ui.add(plot);
|
||||
});
|
||||
|
||||
if egui_state.windows.ecs_entities {
|
||||
if egui_windows.ecs_entities {
|
||||
let ecs = client.state().ecs();
|
||||
|
||||
let positions = client.state().ecs().read_storage::<comp::Pos>();
|
||||
let client_pos = positions.get(client.entity());
|
||||
|
||||
egui::Window::new("ECS Entities")
|
||||
.open(&mut egui_windows.ecs_entities)
|
||||
.default_width(500.0)
|
||||
.default_height(500.0)
|
||||
.show(ctx, |ui| {
|
||||
@ -383,7 +386,6 @@ pub fn maintain_egui_inner(
|
||||
});
|
||||
if let Some(selected_entity_info) = &mut egui_state.selected_entity_info {
|
||||
let selected_entity = ecs.entities().entity(selected_entity_info.entity_id);
|
||||
//let selected_entity_id = selected_entity_info.entity_id;
|
||||
if !selected_entity.gen().is_alive() {
|
||||
previous_selected_entity = mem::take(&mut egui_state.selected_entity_info);
|
||||
} else {
|
||||
|
@ -367,7 +367,7 @@ impl Renderer {
|
||||
|
||||
#[cfg(feature = "egui-ui")]
|
||||
let egui_renderpass =
|
||||
egui_wgpu_backend::RenderPass::new(&*device, TextureFormat::Bgra8UnormSrgb);
|
||||
egui_wgpu_backend::RenderPass::new(&*device, TextureFormat::Bgra8UnormSrgb, 1);
|
||||
|
||||
Ok(Self {
|
||||
device,
|
||||
|
@ -1014,9 +1014,13 @@ impl PlayState for SessionState {
|
||||
|
||||
// Maintain egui (debug interface)
|
||||
#[cfg(feature = "egui-ui")]
|
||||
global_state
|
||||
.egui_state
|
||||
.maintain(&self.client.borrow(), &mut self.scene, &debug_info);
|
||||
if global_state.settings.interface.toggle_debug {
|
||||
global_state.egui_state.maintain(
|
||||
&self.client.borrow(),
|
||||
&mut self.scene,
|
||||
&debug_info,
|
||||
);
|
||||
}
|
||||
|
||||
// Look for changes in the localization files
|
||||
if global_state.i18n.reloaded() {
|
||||
@ -1458,7 +1462,9 @@ impl PlayState for SessionState {
|
||||
drop(third_pass);
|
||||
|
||||
#[cfg(feature = "egui-ui")]
|
||||
drawer.draw_egui(&mut global_state.egui_state.platform, _scale_factor);
|
||||
if global_state.settings.interface.toggle_debug {
|
||||
drawer.draw_egui(&mut global_state.egui_state.platform, _scale_factor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,11 +7,12 @@ use common::debug_info::DebugInfo;
|
||||
use core::mem;
|
||||
use egui::FontDefinitions;
|
||||
use egui_winit_platform::{Platform, PlatformDescriptor};
|
||||
use voxygen_egui::{DebugShapeAction, EguiInnerState};
|
||||
use voxygen_egui::{DebugShapeAction, EguiInnerState, EguiWindows};
|
||||
|
||||
pub struct EguiState {
|
||||
pub platform: Platform,
|
||||
egui_inner_state: EguiInnerState,
|
||||
egui_windows: EguiWindows,
|
||||
new_debug_shape_id: Option<u64>,
|
||||
}
|
||||
|
||||
@ -28,6 +29,7 @@ impl EguiState {
|
||||
Self {
|
||||
platform,
|
||||
egui_inner_state: EguiInnerState::default(),
|
||||
egui_windows: EguiWindows::default(),
|
||||
new_debug_shape_id: None,
|
||||
}
|
||||
}
|
||||
@ -36,6 +38,7 @@ impl EguiState {
|
||||
let egui_actions = voxygen_egui::maintain(
|
||||
&mut self.platform,
|
||||
&mut self.egui_inner_state,
|
||||
&mut self.egui_windows,
|
||||
client,
|
||||
debug_info,
|
||||
mem::take(&mut self.new_debug_shape_id),
|
||||
|
Loading…
Reference in New Issue
Block a user