Skip to content

Commit 55c8c4b

Browse files
committed
feat(controller): add radar + improve critical error logging
1 parent c4b9cb2 commit 55c8c4b

8 files changed

Lines changed: 560 additions & 58 deletions

File tree

Cargo.lock

Lines changed: 145 additions & 32 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controller/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pubg = { path = "../pubg" }
1515
utils-state = { path = "../utils/state" }
1616
utils-console = { path = "../utils/console" }
1717
utils-common = { path = "../utils/common" }
18-
ratatui = { version = "0.26.1", features = ["all-widgets"] }
18+
ratatui = { version = "0.29.0", features = ["all-widgets"] }
1919

2020
once_cell = "1.19"
2121

controller/examples/mock_radar.rs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
use std::{
2+
sync::mpsc,
3+
thread,
4+
time::Duration,
5+
};
6+
7+
use ratatui::text::Line;
8+
use utils_console::{
9+
self,
10+
RadarFrame,
11+
RadarPoint,
12+
};
13+
14+
fn main() {
15+
// Init logger and channels
16+
utils_console::init_logger().expect("logger");
17+
let (log_tx, log_rx) = mpsc::channel::<Vec<Line<'static>>>();
18+
let (radar_tx, radar_rx) = mpsc::channel::<RadarFrame>();
19+
20+
// Mock data producer
21+
thread::spawn(move || {
22+
let mut t: f32 = 0.0;
23+
loop {
24+
// Log some lines
25+
log::info!("[STATUS] Mock radar running");
26+
log::info!("Frame t={:.1}", t);
27+
28+
// Drain logger buffer and forward to TUI
29+
let logs = utils_console::get_and_clear_log_lines();
30+
let _ = log_tx.send(logs);
31+
32+
// Create moving points around player within bounds
33+
let mut points: Vec<RadarPoint> = Vec::new();
34+
for i in 0..20 {
35+
let a = t + (i as f32) * 0.31415926;
36+
let r = 100.0 + ((i * 47) as f32 % 300.0);
37+
let x = r * a.cos();
38+
let y = r * a.sin();
39+
let dz = (((i as i32) % 21) - 10) * 2;
40+
let health = (50 + ((i as i32 * 7 + (t as i32)) % 50)).max(1) as u32;
41+
points.push(RadarPoint { x, y, dz, health });
42+
}
43+
44+
let yaw_deg = (t * 30.0) % 360.0;
45+
let frame = RadarFrame { yaw_deg, points };
46+
let _ = radar_tx.send(frame);
47+
48+
t += 0.1;
49+
thread::sleep(Duration::from_millis(100));
50+
}
51+
});
52+
53+
// Run TUI until user quits with 'q'
54+
if let Err(e) = utils_console::run_tui(log_rx, radar_rx) {
55+
eprintln!("TUI error: {:?}", e);
56+
}
57+
}

0 commit comments

Comments
 (0)