mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
egui feature
This commit is contained in:
parent
cc19e70ae6
commit
da2fd8c7bf
@ -23,11 +23,12 @@ buildInputs = ["xorg.libxcb"]
|
||||
|
||||
[features]
|
||||
hot-anim = ["voxygen-dynlib", "anim/use-dyn-lib"]
|
||||
hot-egui = ["voxygen-dynlib", "voxygen-egui/use-dyn-lib"]
|
||||
hot-egui = ["voxygen-dynlib", "voxygen-egui/use-dyn-lib", "egui",]
|
||||
singleplayer = ["server"]
|
||||
simd = ["vek/platform_intrinsics"]
|
||||
tracy = ["profiling", "profiling/profile-with-tracy", "common/tracy", "common-ecs/tracy", "common-frontend/tracy", "common-net/tracy", "common-systems/tracy", "common-state/tracy", "client/tracy"]
|
||||
plugins = ["client/plugins"]
|
||||
egui-ui = ["voxygen-egui", "egui", "egui_wgpu_backend", "egui_winit_platform"]
|
||||
|
||||
default = ["singleplayer", "native-dialog", "plugins", "simd"]
|
||||
|
||||
@ -43,8 +44,8 @@ common-state = {package = "veloren-common-state", path = "../common/state"}
|
||||
|
||||
anim = {package = "veloren-voxygen-anim", path = "anim"}
|
||||
i18n = {package = "veloren-i18n", path = "i18n"}
|
||||
voxygen-egui = {package = "veloren-voxygen-egui", path = "egui"}
|
||||
voxygen-dynlib = {package = "veloren-voxygen-dynlib", path = "dynlib", optional=true}
|
||||
voxygen-egui = {package = "veloren-voxygen-egui", path = "egui", optional = true }
|
||||
voxygen-dynlib = {package = "veloren-voxygen-dynlib", path = "dynlib", optional = true}
|
||||
|
||||
# Graphics
|
||||
winit = {version = "0.24.0", features = ["serde"]}
|
||||
@ -64,10 +65,10 @@ glyph_brush = "0.7.0"
|
||||
keyboard-keynames = { git = "https://gitlab.com/Frinksy/keyboard-keynames.git", rev = "a97ae509cdb9dc70cf1bf0af762d2d1d3a0d6e0c" }
|
||||
|
||||
# EGUI
|
||||
egui = "0.11"
|
||||
egui_wgpu_backend = "0.7"
|
||||
egui = {version = "0.11", optional = true }
|
||||
egui_wgpu_backend = {version = "0.7", optional = true }
|
||||
#egui_wgpu_backend = { path = "../../egui_wgpu_backend" }
|
||||
egui_winit_platform = "0.6"
|
||||
egui_winit_platform = {version = "0.6", optional = true }
|
||||
#egui_winit_platform = { path = "../../egui_winit_platform" }
|
||||
|
||||
# ECS
|
||||
|
@ -38,11 +38,12 @@ pub use i18n;
|
||||
|
||||
#[cfg(feature = "singleplayer")]
|
||||
use crate::singleplayer::Singleplayer;
|
||||
#[cfg(feature = "egui-ui")]
|
||||
use crate::ui::egui::EguiState;
|
||||
use crate::{
|
||||
audio::AudioFrontend,
|
||||
profile::Profile,
|
||||
settings::Settings,
|
||||
ui::egui::EguiState,
|
||||
window::{Event, Window},
|
||||
};
|
||||
use common::clock::Clock;
|
||||
@ -54,6 +55,7 @@ pub struct GlobalState {
|
||||
pub settings: Settings,
|
||||
pub profile: Profile,
|
||||
pub window: Window,
|
||||
#[cfg(feature = "egui-ui")]
|
||||
pub egui_state: EguiState,
|
||||
pub lazy_init: scene::terrain::SpriteRenderContextLazy,
|
||||
pub audio: AudioFrontend,
|
||||
|
@ -22,6 +22,7 @@ use std::panic;
|
||||
#[cfg(any(feature = "hot-anim", feature = "hot-egui"))]
|
||||
use std::sync::Arc;
|
||||
use tracing::{error, info, warn};
|
||||
#[cfg(feature = "egui-ui")]
|
||||
use veloren_voxygen::ui::egui::EguiState;
|
||||
|
||||
#[allow(clippy::manual_unwrap_or)]
|
||||
@ -206,12 +207,14 @@ fn main() {
|
||||
|
||||
let lazy_init = SpriteRenderContext::new(window.renderer_mut());
|
||||
|
||||
#[cfg(feature = "egui-ui")]
|
||||
let egui_state = EguiState::new(&window);
|
||||
|
||||
let global_state = GlobalState {
|
||||
audio,
|
||||
profile,
|
||||
window,
|
||||
#[cfg(feature = "egui-ui")]
|
||||
egui_state,
|
||||
lazy_init,
|
||||
clock: Clock::new(std::time::Duration::from_secs_f64(
|
||||
|
@ -30,6 +30,7 @@ use super::{
|
||||
use common::assets::{self, AssetExt, AssetHandle};
|
||||
use common_base::span;
|
||||
use core::convert::TryFrom;
|
||||
#[cfg(feature = "egui-ui")]
|
||||
use egui_wgpu_backend::wgpu::TextureFormat;
|
||||
use std::sync::Arc;
|
||||
use tracing::{error, info, warn};
|
||||
@ -137,6 +138,7 @@ pub struct Renderer {
|
||||
profile_times: Vec<wgpu_profiler::GpuTimerScopeResult>,
|
||||
profiler_features_enabled: bool,
|
||||
|
||||
#[cfg(feature = "egui-ui")]
|
||||
egui_renderpass: egui_wgpu_backend::RenderPass,
|
||||
}
|
||||
|
||||
@ -363,6 +365,7 @@ impl Renderer {
|
||||
profiler.enable_timer = mode.profiler_enabled;
|
||||
profiler.enable_debug_marker = mode.profiler_enabled;
|
||||
|
||||
#[cfg(feature = "egui-ui")]
|
||||
let egui_renderpass =
|
||||
egui_wgpu_backend::RenderPass::new(&*device, TextureFormat::Bgra8UnormSrgb);
|
||||
|
||||
@ -397,6 +400,8 @@ impl Renderer {
|
||||
profiler,
|
||||
profile_times: Vec::new(),
|
||||
profiler_features_enabled,
|
||||
|
||||
#[cfg(feature = "egui-ui")]
|
||||
egui_renderpass,
|
||||
})
|
||||
}
|
||||
|
@ -11,7 +11,9 @@ use super::{
|
||||
Renderer, ShadowMap, ShadowMapRenderer,
|
||||
};
|
||||
use core::{num::NonZeroU32, ops::Range};
|
||||
#[cfg(feature = "egui-ui")]
|
||||
use egui_wgpu_backend::ScreenDescriptor;
|
||||
#[cfg(feature = "egui-ui")]
|
||||
use egui_winit_platform::Platform;
|
||||
use std::sync::Arc;
|
||||
use vek::Aabr;
|
||||
@ -55,7 +57,7 @@ impl<'frame> Pipelines<'frame> {
|
||||
struct RendererBorrow<'frame> {
|
||||
queue: &'frame wgpu::Queue,
|
||||
device: &'frame wgpu::Device,
|
||||
sc_desc: &'frame wgpu::SwapChainDescriptor,
|
||||
_sc_desc: &'frame wgpu::SwapChainDescriptor,
|
||||
shadow: Option<&'frame super::Shadow>,
|
||||
pipelines: Pipelines<'frame>,
|
||||
locals: &'frame super::locals::Locals,
|
||||
@ -63,6 +65,7 @@ struct RendererBorrow<'frame> {
|
||||
mode: &'frame super::super::RenderMode,
|
||||
quad_index_buffer_u16: &'frame Buffer<u16>,
|
||||
quad_index_buffer_u32: &'frame Buffer<u32>,
|
||||
#[cfg(feature = "egui-ui")]
|
||||
egui_render_pass: &'frame mut egui_wgpu_backend::RenderPass,
|
||||
}
|
||||
|
||||
@ -104,7 +107,7 @@ impl<'frame> Drawer<'frame> {
|
||||
let borrow = RendererBorrow {
|
||||
queue: &renderer.queue,
|
||||
device: &renderer.device,
|
||||
sc_desc: &renderer.sc_desc,
|
||||
_sc_desc: &renderer.sc_desc,
|
||||
shadow,
|
||||
pipelines,
|
||||
locals: &renderer.locals,
|
||||
@ -112,6 +115,7 @@ impl<'frame> Drawer<'frame> {
|
||||
mode: &renderer.mode,
|
||||
quad_index_buffer_u16: &renderer.quad_index_buffer_u16,
|
||||
quad_index_buffer_u32: &renderer.quad_index_buffer_u32,
|
||||
#[cfg(feature = "egui-ui")]
|
||||
egui_render_pass: &mut renderer.egui_renderpass,
|
||||
};
|
||||
|
||||
@ -266,14 +270,15 @@ impl<'frame> Drawer<'frame> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "egui-ui")]
|
||||
pub fn draw_egui(&mut self, platform: &mut Platform, scale_factor: f32) {
|
||||
let (_output, paint_commands) = platform.end_frame();
|
||||
|
||||
let paint_jobs = platform.context().tessellate(paint_commands);
|
||||
|
||||
let screen_descriptor = ScreenDescriptor {
|
||||
physical_width: self.borrow.sc_desc.width,
|
||||
physical_height: self.borrow.sc_desc.height,
|
||||
physical_width: self.borrow._sc_desc.width,
|
||||
physical_height: self.borrow._sc_desc.height,
|
||||
scale_factor: scale_factor as f32,
|
||||
};
|
||||
|
||||
@ -303,6 +308,7 @@ impl<'frame> Drawer<'frame> {
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(feature = "egui-ui")]
|
||||
pub fn egui_renderpass(&mut self) -> &mut egui_wgpu_backend::RenderPass {
|
||||
self.borrow.egui_render_pass
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ pub fn run(mut global_state: GlobalState, event_loop: EventLoop) {
|
||||
// Continuously run loop since we handle sleeping
|
||||
*control_flow = winit::event_loop::ControlFlow::Poll;
|
||||
|
||||
#[cfg(feature = "egui-ui")]
|
||||
global_state.egui_state.platform.handle_event(&event);
|
||||
// Get events for the ui.
|
||||
if let Some(event) = ui::Event::try_from(&event, global_state.window.window()) {
|
||||
|
@ -1013,6 +1013,7 @@ 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);
|
||||
@ -1396,7 +1397,7 @@ impl PlayState for SessionState {
|
||||
/// This method should be called once per frame.
|
||||
|
||||
fn render(&mut self, global_state: &mut GlobalState) {
|
||||
let scale_factor = global_state.window.window().scale_factor() as f32;
|
||||
let _scale_factor = global_state.window.window().scale_factor() as f32;
|
||||
let renderer = global_state.window.renderer_mut();
|
||||
let settings = &global_state.settings;
|
||||
|
||||
@ -1456,7 +1457,8 @@ impl PlayState for SessionState {
|
||||
|
||||
drop(third_pass);
|
||||
|
||||
drawer.draw_egui(&mut global_state.egui_state.platform, scale_factor);
|
||||
#[cfg(feature = "egui-ui")]
|
||||
drawer.draw_egui(&mut global_state.egui_state.platform, _scale_factor);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,9 +7,9 @@ mod widgets;
|
||||
pub mod img_ids;
|
||||
#[macro_use]
|
||||
pub mod fonts;
|
||||
#[cfg(feature = "egui-ui")] pub mod egui;
|
||||
pub mod ice;
|
||||
pub mod keyed_jobs;
|
||||
pub mod egui;
|
||||
|
||||
pub use event::Event;
|
||||
pub use graphic::{Graphic, Id as GraphicId, Rotation, SampleStrat, Transform};
|
||||
|
Loading…
Reference in New Issue
Block a user