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    ("F5", "Green  [$]"),
16];
17
18pub fn draw(frame: &mut Frame, play_area: Rect) {
19    if play_area.width < 24 || play_area.height < (DEBUG_KEYS.len() as u16 + 3) {
20        return;
21    }
22
23    let w: u16 = 22;
24    let h: u16 = DEBUG_KEYS.len() as u16 + 3; // border × 2 + hint line
25
26    let area = Rect {
27        x: play_area.x,
28        y: play_area.y,
29        width: w,
30        height: h,
31    };
32
33    let mut lines: Vec<Line> = DEBUG_KEYS
34        .iter()
35        .map(|(key, desc)| {
36            Line::from(vec![
37                Span::styled(
38                    format!("{:<3}", key),
39                    Style::default()
40                        .fg(Color::Rgb(255, 200, 90))
41                        .add_modifier(Modifier::BOLD),
42                ),
43                Span::raw(" "),
44                Span::styled(*desc, Style::default().fg(Color::Rgb(200, 200, 210))),
45            ])
46        })
47        .collect();
48
49    lines.push(Line::from(Span::styled(
50        "--no-debug: disable",
51        Style::default().fg(Color::Rgb(110, 110, 120)),
52    )));
53
54    let block = Block::bordered()
55        .title(" DEBUG ")
56        .border_style(Style::default().fg(Color::Rgb(180, 140, 60)));
57    let p = Paragraph::new(lines).block(block);
58    frame.render_widget(Clear, area);
59    frame.render_widget(p, area);
60}