editor with imgui and sdl->28
This commit is contained in:
82
src/editor/mod.rs
Normal file
82
src/editor/mod.rs
Normal file
@@ -0,0 +1,82 @@
|
||||
mod inspector;
|
||||
|
||||
use sdl3_sys::events::SDL_Event;
|
||||
|
||||
use crate::entity::EntityHandle;
|
||||
use crate::systems::camera_noclip_system;
|
||||
use crate::utility::input::InputState;
|
||||
use crate::world::World;
|
||||
|
||||
pub use inspector::FrameStats;
|
||||
use inspector::Inspector;
|
||||
|
||||
pub struct EditorState
|
||||
{
|
||||
pub active: bool,
|
||||
pub right_mouse_held: bool,
|
||||
pub selected_entity: Option<EntityHandle>,
|
||||
inspector: Inspector,
|
||||
}
|
||||
|
||||
impl EditorState
|
||||
{
|
||||
pub fn new(
|
||||
device: &wgpu::Device,
|
||||
queue: &wgpu::Queue,
|
||||
surface_format: wgpu::TextureFormat,
|
||||
) -> Self
|
||||
{
|
||||
Self {
|
||||
active: false,
|
||||
right_mouse_held: false,
|
||||
selected_entity: None,
|
||||
inspector: Inspector::new(device, queue, surface_format),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn init_platform(&mut self, window: &sdl3::video::Window)
|
||||
{
|
||||
self.inspector.init_platform(window);
|
||||
}
|
||||
|
||||
pub fn begin_frame(&mut self)
|
||||
{
|
||||
self.inspector.begin_frame();
|
||||
}
|
||||
|
||||
pub fn process_event(&mut self, raw_event: &SDL_Event) -> bool
|
||||
{
|
||||
self.inspector.process_event(raw_event);
|
||||
false
|
||||
}
|
||||
|
||||
pub fn wants_keyboard(&self) -> bool
|
||||
{
|
||||
self.inspector.wants_keyboard()
|
||||
}
|
||||
|
||||
pub fn wants_mouse(&self) -> bool
|
||||
{
|
||||
self.inspector.wants_mouse()
|
||||
}
|
||||
|
||||
pub fn render(&mut self, encoder: &mut wgpu::CommandEncoder, view: &wgpu::TextureView)
|
||||
{
|
||||
self.inspector.render(encoder, view);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn editor_loop(
|
||||
editor: &mut EditorState,
|
||||
world: &mut World,
|
||||
input_state: &InputState,
|
||||
stats: &FrameStats,
|
||||
delta: f32,
|
||||
)
|
||||
{
|
||||
if editor.right_mouse_held
|
||||
{
|
||||
camera_noclip_system(world, input_state, delta);
|
||||
}
|
||||
editor.inspector.build_ui(stats);
|
||||
}
|
||||
Reference in New Issue
Block a user