docs: README, dead-code cleanup, smoke fixes

- README with run instructions and key reference
- lift the crate-level dead_code allowance; scope it to the anim library surface
- render paths tolerate a city that is still generating (district/building ids
  without entries), found by driving the app through a pty
- status messages show in the status bar, not only inside the inspector
- buffered JSON export (26 s -> 0.4 s for a large city)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Jeffrey Wilcke
2026-10-12 18:02:14 +02:00
parent 48320eb0e6
commit 3c75674489
15 changed files with 180 additions and 37 deletions

View File

@@ -188,14 +188,19 @@ impl Widget for MapView<'_> {
.unwrap_or(Visibility::Visible);
let ctx = RenderCtx {
style: self.style,
theme: tile.district.map(|d| self.city.district(d).theme),
theme: tile
.district
.and_then(|d| self.city.district_opt(d))
.map(|d| d.theme),
stratum: self.stratum,
light: st.light.get(p).copied().unwrap_or(0),
tick: self.tick,
pos: p,
vis,
connector,
kind: tile.building.map(|b| self.city.building(b).kind),
kind: tile
.building
.and_then(|b| self.city.building_opt(b))
.map(|b| b.kind),
wall_mask: mask,
};
apply_vis(cell(tile, &ctx), vis).write(buf, sx, sy);
@@ -282,6 +287,46 @@ mod tests {
);
}
#[test]
fn mapview_renders_every_partial_generation_state() {
use citygen::{Generator, Progress};
let s = StylePack::load().unwrap();
let mut g = Generator::new(GenParams {
seed: 11,
size: SizePreset::Custom { w: 80, h: 40 },
districts: 4,
..Default::default()
})
.unwrap();
let mut t = Terminal::new(TestBackend::new(90, 45)).unwrap();
let mut steps = 0u32;
loop {
let progress = g.step();
steps += 1;
if steps.is_multiple_of(7) || matches!(progress, Progress::Done) {
for k in StratumKind::PHYSICAL {
t.draw(|f| {
MapView {
city: g.city(),
stratum: k,
origin: Pos::new(-2, -2),
tick: steps as u64,
style: &s,
vis: None,
overlays: &[&Weather],
cursor: None,
}
.render(f.area(), f.buffer_mut())
})
.unwrap();
}
}
if matches!(progress, Progress::Done) {
break;
}
}
}
#[test]
fn camera_follow_has_deadzone_and_eases() {
let mut cam = Camera::default();