Skip to main content

cuqueclicker_lib/ui/
debug_pane.rs

1use ratatui::{prelude::*, widgets::*};
2
3/// Keys advertised in the debug pane. One source of truth for both the
4/// rendered rows and the hotkey dispatch in `input.rs`.
5///
6/// `F8` is the Lucky-spawn cheat instead of `F1` because Chrome (and most
7/// browsers) hijack `F1` for "Help" and never deliver the keydown to the
8/// page. `F8` has no default browser binding outside of an open DevTools
9/// instance, so it's safe on both web and native.
10pub const DEBUG_KEYS: &[(&str, &str)] = &[
11    ("F8", "Lucky  [$]"),
12    ("F2", "Frenzy [!]"),
13    ("F3", "Buff   [+]"),
14    ("F4", "+1M cuques"),
15];
16
17pub fn draw(frame: &mut Frame, play_area: Rect) {
18    if play_area.width < 24 || play_area.height < (DEBUG_KEYS.len() as u16 + 3) {
19        return;
20    }
21
22    let w: u16 = 22;
23    let h: u16 = DEBUG_KEYS.len() as u16 + 3; // border × 2 + hint line
24
25    let area = Rect {
26        x: play_area.x,
27        y: play_area.y,
28        width: w,
29        height: h,
30    };
31
32    let mut lines: Vec<Line> = DEBUG_KEYS
33        .iter()
34        .map(|(key, desc)| {
35            Line::from(vec![
36                Span::styled(
37                    format!("{:<3}", key),
38                    Style::default()
39                        .fg(Color::Rgb(255, 200, 90))
40                        .add_modifier(Modifier::BOLD),
41                ),
42                Span::raw(" "),
43                Span::styled(*desc, Style::default().fg(Color::Rgb(200, 200, 210))),
44            ])
45        })
46        .collect();
47
48    lines.push(Line::from(Span::styled(
49        "--no-debug: disable",
50        Style::default().fg(Color::Rgb(110, 110, 120)),
51    )));
52
53    let block = Block::bordered()
54        .title(" DEBUG ")
55        .border_style(Style::default().fg(Color::Rgb(180, 140, 60)));
56    let p = Paragraph::new(lines).block(block);
57    frame.render_widget(Clear, area);
58    frame.render_widget(p, area);
59}