Skip to content

Commit

Permalink
Add (unused) keybinding for fullscreen to settings::Stevenkey::FullSc…
Browse files Browse the repository at this point in the history
…reen
  • Loading branch information
iceiix committed Nov 21, 2018
1 parent d4037c4 commit 186496d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ fn handle_window_event(window: &sdl2::video::Window,
Event::KeyDown{keycode: Some(Keycode::Backquote), ..} => {
game.console.lock().unwrap().toggle();
}
Event::KeyDown{keycode: Some(Keycode::F11), ..} => {
Event::KeyDown{keycode: Some(Keycode::F11), ..} => { // TODO: use settings::Stevenkey::FullScreen
println!("TODO: toggle fullscreen");
}
Event::KeyDown{keycode: Some(key), keymod, ..} => {
Expand Down
8 changes: 6 additions & 2 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ pub const CL_KEYBIND_OPEN_INV: console::CVar<i64> = create_keybind!(E, "cl_keybi
pub const CL_KEYBIND_SNEAK: console::CVar<i64> = create_keybind!(LShift, "cl_keybind_sneak", "Keybinding for sneaking");
pub const CL_KEYBIND_SPRINT: console::CVar<i64> = create_keybind!(LCtrl, "cl_keybind_sprint", "Keybinding for sprinting");
pub const CL_KEYBIND_JUMP: console::CVar<i64> = create_keybind!(Space, "cl_keybind_jump", "Keybinding for jumping");
pub const CL_KEYBIND_FULLSCREEN: console::CVar<i64> = create_keybind!(Space, "cl_keybind_fullscreen", "Keybinding for full screen");

pub fn register_vars(vars: &mut console::Vars) {
vars.register(R_MAX_FPS);
Expand All @@ -72,6 +73,7 @@ pub fn register_vars(vars: &mut console::Vars) {
vars.register(CL_KEYBIND_SNEAK);
vars.register(CL_KEYBIND_SPRINT);
vars.register(CL_KEYBIND_JUMP);
vars.register(CL_KEYBIND_FULLSCREEN);
}

#[derive(Hash, PartialEq, Eq)]
Expand All @@ -84,13 +86,14 @@ pub enum Stevenkey {
Sneak,
Sprint,
Jump,
FullScreen,
}

impl Stevenkey {
pub fn values() -> Vec<Stevenkey> {
vec!(Stevenkey::Forward, Stevenkey::Backward, Stevenkey::Left,
Stevenkey::Right, Stevenkey::OpenInv, Stevenkey::Sneak,
Stevenkey::Sprint, Stevenkey::Jump)
Stevenkey::Sprint, Stevenkey::Jump, Stevenkey::FullScreen)
}

pub fn get_by_keycode(keycode: Keycode, vars: &console::Vars) -> Option<Stevenkey> {
Expand All @@ -111,7 +114,8 @@ impl Stevenkey {
Stevenkey::OpenInv => CL_KEYBIND_OPEN_INV,
Stevenkey::Sneak => CL_KEYBIND_SNEAK,
Stevenkey::Sprint => CL_KEYBIND_SPRINT,
Stevenkey::Jump => CL_KEYBIND_JUMP
Stevenkey::Jump => CL_KEYBIND_JUMP,
Stevenkey::FullScreen => CL_KEYBIND_FULLSCREEN,
}
}
}

0 comments on commit 186496d

Please sign in to comment.