1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
//! Temporary: prints screens for a UI review.
use super::tests::test_ctx;
use super::*;
use ratatui::Terminal;
use ratatui::backend::TestBackend;
use ratatui::crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
fn show(name: &str, scene: &dyn Scene, ctx: &Ctx, w: u16, h: u16) {
let mut t = Terminal::new(TestBackend::new(w, h)).unwrap();
t.draw(|f| scene.render(f, ctx)).unwrap();
let b = t.backend().buffer();
let cells: Vec<&str> = b.content.iter().map(|c| c.symbol()).collect();
println!("===== {name} ({w}x{h})");
for row in cells.chunks(w as usize) {
println!("{}", row.concat().trim_end());
}
}
fn k(s: &mut dyn Scene, ctx: &mut Ctx, c: KeyCode) {
s.key(KeyEvent::new(c, KeyModifiers::NONE), ctx);
}
#[test]
fn zz_dump() {
let mut ctx = test_ctx();
let dir = crate::save::scratch("dump");
ctx.saves = Some(dir.clone());
ctx.slot = Some(crate::save::new_slot(&dir, &ctx.character, ctx.seed));
ctx.autosave();
let (w, h) = (120, 40);
show("title", &title::Title::new(&ctx), &ctx, w, h);
show("create", &character::Create::new(&ctx), &ctx, w, h);
show("sheet", &character::Sheet::new(), &ctx, w, h);
show("saves", &saves::Saves::new(&ctx), &ctx, w, h);
show("forge", &forge::Forge::new(&ctx), &ctx, w, h);
let home = ctx.system.home_place();
let mut a = aboard::Aboard::landed(&ctx, home);
show("aboard", &a, &ctx, w, h);
k(&mut a, &mut ctx, KeyCode::Esc);
show("aboard pause", &a, &ctx, w, h);
let mut a = aboard::Aboard::landed(&ctx, home);
k(&mut a, &mut ctx, KeyCode::Char('i'));
show("aboard inv", &a, &ctx, w, h);
let mut t = town::TownScene::new(&ctx, home);
show("town", &t, &ctx, w, h);
k(&mut t, &mut ctx, KeyCode::Char('m'));
show("town map", &t, &ctx, w, h);
let mut f = flight::FlightScene::new(&ctx);
show("flight", &f, &ctx, w, h);
show("flight narrow", &f, &ctx, 80, 24);
show("aboard 80", &aboard::Aboard::landed(&ctx, home), &ctx, 80, 24);
show("derelict 80", &derelict::Derelict::new(2), &ctx, 80, 24);
k(&mut f, &mut ctx, KeyCode::Esc);
show("flight pause", &f, &ctx, w, h);
show("system map", &system_map::SystemMap::new(&ctx), &ctx, w, h);
show("galaxy map", &galaxy_map::GalaxyMap::new(&ctx), &ctx, w, h);
show("port station", &port::Port::new(&ctx, 0), &ctx, w, h);
let mut d = derelict::Derelict::board(2, &mut ctx);
show("derelict", &d, &ctx, w, h);
k(&mut d, &mut ctx, KeyCode::Char('f'));
show("derelict aim", &d, &ctx, w, h);
let _ = std::fs::remove_dir_all(dir);
}
|