Skip to content

Commit

Permalink
Updated default dev environment logging to debug except for wgpu (war…
Browse files Browse the repository at this point in the history
…n). Done through direnv. We also don't need to center the cursor every frame if we're grabbing it properly.
  • Loading branch information
fourbytes committed May 8, 2020
1 parent 21503a6 commit 6829cfa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export RUST_LOG=debug,wgpu_core=warn
2 changes: 1 addition & 1 deletion client/src/singleplayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 3 additions & 10 deletions client/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down Expand Up @@ -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,
};

Expand Down Expand Up @@ -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),
_ => ()
Expand Down

0 comments on commit 6829cfa

Please sign in to comment.