Finish radar truth HUD layout and document target modes (#132)
build / mod (push) Failing after 33s
build / mod (push) Failing after 33s
Co-Authored-By: Kimi Code <noreply@moonshot.ai>
This commit is contained in:
@@ -871,7 +871,8 @@ impl AirDef {
|
||||
}
|
||||
self.hud_shown = true;
|
||||
hud::set_panel(Corner::TopRight, &panel::summary(&self.sim, &pic, player));
|
||||
render::set_corner(render::Corner::BottomRight, radar::SIZE, radar::SIZE + 12.0, &radar::draw(&self.sim, player, yaw));
|
||||
let truth_label = self.sim.truth && !pic.unaided;
|
||||
render::set_corner(render::Corner::BottomRight, radar::SIZE, radar::height(truth_label), &radar::draw(&self.sim, player, yaw));
|
||||
}
|
||||
|
||||
// ------------------------------------------------ saving
|
||||
|
||||
@@ -2904,11 +2904,7 @@ mod tests {
|
||||
let id = sim.drones[0].id;
|
||||
let sid = sim.id();
|
||||
sim.sams.push(Sam::new(sid, SamKind::Buk, DVec3::new(0.0, 64.0, 500.0), 0.0));
|
||||
let mut ui = MapUi::default();
|
||||
ui.size = (800.0, 600.0);
|
||||
ui.centre = (0.0, 0.0);
|
||||
ui.scale = 1.0;
|
||||
ui.cursor = (400.0, 300.0);
|
||||
let ui = MapUi { size: (800.0, 600.0), centre: (0.0, 0.0), scale: 1.0, cursor: (400.0, 300.0), ..Default::default() };
|
||||
(sim, id, ui)
|
||||
}
|
||||
|
||||
|
||||
+12
-2
@@ -8,6 +8,10 @@ use horizon_mod_sdk::render::{FillShape, Point, QuadShape, Rect, Shape, TextShap
|
||||
|
||||
/// The scope's side in GUI pixels.
|
||||
pub const SIZE: f32 = 112.0;
|
||||
/// The corner box's height: the scope and its range label, plus the truth mode's own line when it shows one.
|
||||
pub fn height(truth_label: bool) -> f32 {
|
||||
SIZE + if truth_label { 22.0 } else { 12.0 }
|
||||
}
|
||||
/// Blocks from the centre to the edge.
|
||||
const RANGE: f64 = 500.0;
|
||||
const SEGMENTS: usize = 48;
|
||||
@@ -38,7 +42,7 @@ fn alpha(rgb: u32, a: f64) -> u32 {
|
||||
}
|
||||
|
||||
/// A track's blip: a shape by the class the radar measured, pointing along the course where there is one.
|
||||
/// Дrones are triangles, jets darts, cruise squares, supersonic diamonds, ballistic octagons.
|
||||
/// Drones are triangles, jets darts, cruise squares, supersonic diamonds, ballistic octagons.
|
||||
fn blip(class: Class, x: f32, y: f32, color: u32, vel: DVec3) -> Vec<Shape> {
|
||||
let h = DVec3::new(vel.x, 0.0, vel.z).normalize_or_zero();
|
||||
let (hx, hy) = if h == DVec3::ZERO { (0.0, -1.0) } else { (h.x as f32, h.z as f32) };
|
||||
@@ -324,6 +328,12 @@ mod tests {
|
||||
assert!(!plain.iter().any(|s| matches!(s, Shape::Text(t) if t.text.contains("ИСТИНА"))));
|
||||
sim.truth = true;
|
||||
let shapes = draw(&sim, DVec3::ZERO, 0.0);
|
||||
assert!(shapes.iter().any(|s| matches!(s, Shape::Text(t) if t.text.contains("ИСТИНА") && t.text.contains("песочница"))), "the truth mode is not marked");
|
||||
let label = shapes.iter().find_map(|s| match s {
|
||||
Shape::Text(t) if t.text.contains("ИСТИНА") && t.text.contains("песочница") => Some(t),
|
||||
_ => None,
|
||||
}).expect("the truth mode is not marked");
|
||||
// The corner box is sized to hold the label: a line of the HUD font is 9 pixels with its shadow.
|
||||
assert!(label.at.y + 9.0 <= height(true), "the truth label falls outside the corner box");
|
||||
assert!(height(true) > height(false));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user