diff --git a/src/main.rs b/src/main.rs index 58e0c08..4d80ed0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -74,6 +74,7 @@ fn run(config: &Config) -> Result<()> { let mut show_search = false; let mut search_query = String::new(); let mut search_results: Vec = Vec::new(); + let mut show_help = false; if let Some(ref video_path) = config.video { info!("Loading video: {:?}", video_path); @@ -182,10 +183,15 @@ fn run(config: &Config) -> Result<()> { show_search = false; search_query.clear(); search_results.clear(); + } else if show_help { + show_help = false; } else { running = false; } } + sdl2::keyboard::Keycode::H => { + show_help = !show_help; + } sdl2::keyboard::Keycode::Slash => { if searcher.is_some() { show_search = true; @@ -824,6 +830,70 @@ fn run(config: &Config) -> Result<()> { } } + if show_help { + if let Some(ref font) = font { + let help_lines = vec![ + "MoMentry Playground - Keyboard Shortcuts", + "", + "=== Playback ===", + "Space Play / Pause", + "Home Jump to start", + "End Jump to end", + "Left/Right Frame step (Shift for 1 sec)", + "", + "=== Display ===", + "S Toggle subtitles", + "Y Toggle YOLO boxes", + "C Toggle chunk markers", + "F Toggle fullscreen", + "M Mute / Unmute", + "+/- Zoom in / out", + "0 or ` Reset zoom", + "Arrow keys Pan when zoomed", + "", + "=== Search ===", + "/ Open search panel", + "Enter Search", + "1-6 Jump to result", + "Esc Close panel", + "", + "=== Other ===", + "H Toggle this help", + "Esc Exit", + ]; + + let line_height = 18u32; + let help_h = (help_lines.len() as u32) * line_height + 40; + let help_w = 380u32; + let help_x = (config.width as i32 - help_w as i32) / 2; + let help_y = (config.height as i32 - help_h as i32) / 2; + + canvas.set_draw_color(sdl2::pixels::Color::RGBA(15, 15, 25, 245)); + let _ = canvas.fill_rect(Rect::new(help_x, help_y, help_w, help_h)); + canvas.set_draw_color(sdl2::pixels::Color::RGBA(80, 80, 120, 255)); + let _ = canvas.draw_rect(Rect::new(help_x, help_y, help_w, help_h)); + + let mut y_offset = help_y + 15; + for (i, line) in help_lines.iter().enumerate() { + let color = if line.ends_with("===") || line.is_empty() { + sdl2::pixels::Color::RGB(120, 180, 255) + } else if line.starts_with("===") { + sdl2::pixels::Color::RGB(100, 100, 120) + } else { + sdl2::pixels::Color::RGB(200, 200, 200) + }; + if let Ok(surface) = font.render(line).solid(color) { + if let Ok(tex) = texture_creator.create_texture_from_surface(&surface) { + let rect = + Rect::new(help_x + 20, y_offset, surface.width(), surface.height()); + canvas.copy(&tex, None, Some(rect)).ok(); + } + } + y_offset += line_height as i32; + } + } + } + canvas.present(); std::thread::sleep(std::time::Duration::from_millis(16)); }