From 64d5d2c70823282646efe54c384bc88a228b04d3 Mon Sep 17 00:00:00 2001 From: Oscar Rainford Date: Fri, 8 May 2020 15:20:26 +1000 Subject: [PATCH] Updated default dev environment logging to debug except for wgpu (warn). Done through direnv. We also don't need to center the cursor every frame if we're grabbing it properly. --- .envrc | 1 + client/src/singleplayer.rs | 2 +- client/src/window.rs | 13 +++---------- 3 files changed, 5 insertions(+), 11 deletions(-) create mode 100644 .envrc diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..cfd73cf --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +export RUST_LOG=debug,wgpu_core=warn,gfx_backend_vulkan=warn diff --git a/client/src/singleplayer.rs b/client/src/singleplayer.rs index 17b79f7..79c644b 100644 --- a/client/src/singleplayer.rs +++ b/client/src/singleplayer.rs @@ -252,7 +252,7 @@ impl State for SinglePlayer { }); self.client_timing.record_part("Drop far chunks"); - flags.hide_and_center_cursor = self.ui.should_capture_mouse(); + flags.grab_cursor = self.ui.should_capture_mouse(); send_debug_info( "Chunks", diff --git a/client/src/window.rs b/client/src/window.rs index bc5ff69..7040097 100644 --- a/client/src/window.rs +++ b/client/src/window.rs @@ -41,7 +41,7 @@ pub struct WindowData { #[derive(Debug, Clone)] pub struct WindowFlags { /// `true` if the cursor should be hidden and centered. - pub hide_and_center_cursor: bool, + pub grab_cursor: bool, /// Window title pub window_title: String, } @@ -169,7 +169,7 @@ pub fn open_window(mut settings: Settings, initial_state: StateFactory) -> ! { let mut input_state = InputState::new(); let mut window_flags = WindowFlags { - hide_and_center_cursor: false, + grab_cursor: false, window_title, }; @@ -284,16 +284,9 @@ pub fn open_window(mut settings: Settings, initial_state: StateFactory) -> ! { // Update window flags window.set_title(&window_flags.window_title); - if window_flags.hide_and_center_cursor && window_data.focused { + if window_flags.grab_cursor && window_data.focused { window.set_cursor_visible(false); let sz = window_data.logical_window_size; - match window.set_cursor_position(winit::dpi::LogicalPosition { - x: sz.width / 2.0, - y: sz.height / 2.0, - }) { - Err(err) => warn!("Failed to center cursor ({:?})", err), - _ => () - }; match window.set_cursor_grab(true) { Err(err) => warn!("Failed to grab cursor ({:?})", err), _ => ()