diff --git a/README.md b/README.md index ededb36..3f85ffe 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ Links: # Key Bindings +- F1: Show key bindings - Space: Slow down (or match velocity) - AWSD/Shift/Ctrl: Accelerate - R: Rotate (hold & move mouse) diff --git a/src/chat.rs b/src/chat.rs index 97519c8..5e6969f 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -691,6 +691,11 @@ pub fn handle_chat_events( hud::LogLevel::Warning => { log.warning(message.into()); } + hud::LogLevel::Always => { + log.add(message.into(), + chat.talker.name.clone().unwrap_or("".to_string()), + hud::LogLevel::Always); + } } chat.timer = now + ((message.len() as f32).max(CHAT_SPEED_MIN_LEN) * TALKER_SPEED_FACTOR * chat.talker.talking_speed / settings.chat_speed) as f64; diff --git a/src/data/keybindings.in b/src/data/keybindings.in new file mode 100644 index 0000000..b81e13a --- /dev/null +++ b/src/data/keybindings.in @@ -0,0 +1,20 @@ +X: Teleport to target [CHEAT] +C: Impossibly instant stopping [CHEAT] +Shift+V/B: Same as V/B, but a thousand times faster [CHEAT] +V/B: Impossible acceleration forward/backward [CHEAT] +G: Toggle god mode / cheats [CHEAT] +M: Toggle sound effects +T: Toggle music +Y: Toggle rotation stabilizer +F: Toggle 3rd person view +F11: Toggle fullscreen +Tab: Toggle HUD + Augmented Reality +Right click: Zoom [AUGMENTED REALITY ONLY] +Left click: Target objects [AUGMENTED REALITY ONLY] +JKULIO: Mouseless camera rotation +F7: Restart game +Q: Exit vehicle +E: Interact: Talk to people, enter vehicles +R: Rotate (hold & move mouse) +AWSD/Shift/Ctrl: Accelerate +Space: Slow down (or match velocity) diff --git a/src/hud.rs b/src/hud.rs index 044f0c4..c2303d9 100644 --- a/src/hud.rs +++ b/src/hud.rs @@ -9,9 +9,9 @@ use std::time::SystemTime; pub const HUD_REFRESH_TIME: f32 = 0.1; pub const FONT: &str = "fonts/Yupiter-Regular.ttf"; -pub const LOG_MAX: usize = 16; pub const LOG_MAX_TIME_S: f64 = 30.0; pub const LOG_MAX_ROWS: usize = 30; +pub const LOG_MAX: usize = LOG_MAX_ROWS; pub const MAX_CHOICES: usize = 10; pub const AMBIENT_LIGHT: f32 = 0.0; // Space is DARK pub const AMBIENT_LIGHT_AR: f32 = 15.0; @@ -74,6 +74,7 @@ pub struct AugmentedRealityOverlay { struct FPSUpdateTimer(Timer); pub enum LogLevel { + Always, Warning, //Error, Info, @@ -234,6 +235,9 @@ fn setup( )); // Add Console + // This one is intentionally NOT a ToggleableHudElement. Instead, console entries + // are filtered based on whether the hud is active or not. LogLevel::Always is + // even shown when hud is inactive. let bundle_chatbox = TextBundle::from_sections((0..LOG_MAX_ROWS).map(|_| TextSection::new("", style_console.clone())) ).with_style(Style { @@ -243,7 +247,6 @@ fn setup( ..default() }).with_text_justify(JustifyText::Right); commands.spawn(( - ToggleableHudElement, NodeBundle { style: Style { width: Val::Percent(50.0), @@ -253,7 +256,6 @@ fn setup( right: Val::VMin(3.0), ..default() }, - visibility, ..default() }, )).with_children(|parent| { @@ -503,7 +505,16 @@ fn update_hud( let mut row = 0; // Chat Log and System Log + let logfilter = if settings.hud_active { + |_msg: &&Message| { true } + } else { + |msg: &&Message| { match msg.level { + LogLevel::Always => true, + _ => false + }} + }; let messages: Vec<&Message> = log.logs.iter() + .filter(logfilter) .rev() .take(LOG_MAX_ROWS) .collect(); @@ -591,6 +602,7 @@ fn handle_input( keyboard_input: Res>, mouse_input: Res>, mut settings: ResMut, + mut log: ResMut, mut q_hud: Query<(&mut Visibility, Option<&OnlyHideWhenTogglingHud>), With>, mut ew_sfx: EventWriter, mut ew_togglemusic: EventWriter, @@ -599,6 +611,11 @@ fn handle_input( q_objects: Query<(Entity, &Transform), (With, Without, Without, Without)>, q_camera: Query<&Transform, With>, ) { + if keyboard_input.just_pressed(settings.key_help) { + for line in include_str!("data/keybindings.in").trim().split("\n") { + log.add(line.to_string(), "".to_string(), LogLevel::Always); + } + } if keyboard_input.just_pressed(settings.key_togglehud) { if settings.hud_active { for (mut hudelement_visibility, _) in q_hud.iter_mut() { diff --git a/src/var.rs b/src/var.rs index 8ccbbcb..dc2adb1 100644 --- a/src/var.rs +++ b/src/var.rs @@ -49,6 +49,7 @@ pub struct Settings { pub key_exit: KeyCode, pub key_restart: KeyCode, pub key_fullscreen: KeyCode, + pub key_help: KeyCode, pub key_forward: KeyCode, pub key_back: KeyCode, pub key_left: KeyCode, @@ -130,7 +131,7 @@ impl Default for Settings { hud_color_console: Color::rgb(0.2, 0.5, 0.2), hud_color_console_warn: Color::rgb(1.0, 0.3, 0.3), hud_color_console_system: Color::rgb(0.5, 0.5, 0.5), - hud_color_alert: Color::rgb(0.7, 0.3, 0.3), + hud_color_alert: Color::rgb(0.8, 0.3, 0.5), hud_color_subtitles: Color::rgb(0.8, 0.8, 0.8), hud_color_choices: Color::rgb(0.45, 0.45, 0.45), chat_speed: DEFAULT_CHAT_SPEED * if dev_mode { 2.5 } else { 1.0 }, @@ -144,6 +145,7 @@ impl Default for Settings { key_exit: KeyCode::Escape, key_restart: KeyCode::F7, key_fullscreen: KeyCode::F11, + key_help: KeyCode::F1, key_forward: KeyCode::KeyW, key_back: KeyCode::KeyS, key_left: KeyCode::KeyA,