diff --git a/comfy/src/game_loop.rs b/comfy/src/game_loop.rs index c8e29fc..8f2cee5 100644 --- a/comfy/src/game_loop.rs +++ b/comfy/src/game_loop.rs @@ -92,15 +92,15 @@ pub async fn run_comfy_main_async( // Winit prevents sizing with CSS, so we have to set // the size manually when on web. use winit::dpi::PhysicalSize; - window.set_min_inner_size(PhysicalSize::new( + window.set_min_inner_size(Some(PhysicalSize::new( resolution.width(), resolution.height(), - )); + ))); - window.set_max_inner_size(PhysicalSize::new( + window.set_max_inner_size(Some(PhysicalSize::new( resolution.width(), resolution.height(), - )); + ))); use winit::platform::web::WindowExtWebSys; web_sys::window() @@ -124,7 +124,6 @@ pub async fn run_comfy_main_async( .expect("Couldn't append canvas to document body."); } - let scale_factor = game_config() .scale_factor_override .unwrap_or(window.scale_factor() as f32); @@ -204,7 +203,6 @@ pub async fn run_comfy_main_async( .set_cursor_visible(!global_state.cursor_hidden); } - set_frame_time(frame_start.elapsed().as_secs_f32()); inc_frame_num(); @@ -220,36 +218,32 @@ pub async fn run_comfy_main_async( tracy_client::frame_mark(); } - Event::DeviceEvent { event, .. } => { - match event { - DeviceEvent::Key(input) => { - if let Some(keycode) = - KeyCode::try_from_winit(input.physical_key) - { - match input.state { - ElementState::Pressed => { - let mut state = - GLOBAL_STATE.borrow_mut(); - - state.pressed.insert(keycode); - state.just_pressed.insert(keycode); - state.just_released.remove(&keycode); - } - - ElementState::Released => { - let mut state = - GLOBAL_STATE.borrow_mut(); - - state.pressed.remove(&keycode); - state.just_pressed.remove(&keycode); - state.just_released.insert(keycode); - } + Event::DeviceEvent { event, .. } => match event { + DeviceEvent::Key(input) => { + if let Some(keycode) = + KeyCode::try_from_winit(input.physical_key) + { + match input.state { + ElementState::Pressed => { + let mut state = GLOBAL_STATE.borrow_mut(); + + state.pressed.insert(keycode); + state.just_pressed.insert(keycode); + state.just_released.remove(&keycode); + } + + ElementState::Released => { + let mut state = GLOBAL_STATE.borrow_mut(); + + state.pressed.remove(&keycode); + state.just_pressed.remove(&keycode); + state.just_released.insert(keycode); } } } - _ => {} } - } + _ => {} + }, Event::WindowEvent { ref event, window_id: _ } => { if engine.renderer.as_mut().unwrap().on_event(event, egui()) { @@ -335,8 +329,8 @@ pub async fn run_comfy_main_async( } WindowEvent::Resized(physical_size) => { - if physical_size.width > min_resolution.0 && - physical_size.height > min_resolution.1 + if physical_size.width > min_resolution.0 + && physical_size.height > min_resolution.1 { engine.resize(uvec2( physical_size.width,