This commit is contained in:
Quaternions 2025-01-03 02:31:43 -08:00
parent ff011f9f0c
commit cbdc389cc9

View File

@ -16,15 +16,15 @@ struct WindowContext<'a>{
mouse:strafesnet_common::mouse::MouseState,//std::sync::Arc<std::sync::Mutex<>>
screen_size:glam::UVec2,
window:&'a winit::window::Window,
physics_thread:crate::compat_worker::QNWorker<'a, TimedInstruction<crate::physics_worker::Instruction>>,
physics_thread:crate::compat_worker::QNWorker<'a,TimedInstruction<crate::physics_worker::Instruction>>,
}
impl WindowContext<'_>{
fn get_middle_of_screen(&self)->winit::dpi::PhysicalPosition<u32>{
winit::dpi::PhysicalPosition::new(self.screen_size.x/2,self.screen_size.y/2)
}
fn window_event(&mut self,time:integer::Time,event: winit::event::WindowEvent) {
match event {
fn window_event(&mut self,time:integer::Time,event:winit::event::WindowEvent){
match event{
winit::event::WindowEvent::DroppedFile(path)=>{
match crate::file::load(path.as_path()){
Ok(map)=>self.physics_thread.send(TimedInstruction{time,instruction:crate::physics_worker::Instruction::ChangeMap(map)}).unwrap(),
@ -122,11 +122,11 @@ impl WindowContext<'_>{
}
}
fn device_event(&mut self,time:integer::Time,event: winit::event::DeviceEvent) {
match event {
winit::event::DeviceEvent::MouseMotion {
fn device_event(&mut self,time:integer::Time,event: winit::event::DeviceEvent){
match event{
winit::event::DeviceEvent::MouseMotion{
delta,//these (f64,f64) are integers on my machine
} => {
}=>{
if self.manual_mouse_lock{
match self.window.set_cursor_position(self.get_middle_of_screen()){
Ok(())=>(),
@ -145,7 +145,7 @@ impl WindowContext<'_>{
},
winit::event::DeviceEvent::MouseWheel {
delta,
} => {
}=>{
println!("mousewheel {:?}",delta);
if false{//self.physics.style.use_scroll{
self.physics_thread.send(TimedInstruction{
@ -153,7 +153,7 @@ impl WindowContext<'_>{
instruction:crate::physics_worker::Instruction::Input(InputInstruction::Jump(true)),//activates the immediate jump path, but the style modifier prevents controls&CONTROL_JUMP bit from being set to auto jump
}).unwrap();
}
}
},
_=>(),
}
}