`cargo fmt --all -- --check` has failed on every run in this repository's history, identically on `main` and on every branch. This is #12. Mechanical: `cargo fmt --all`, nothing else. 154 files, all `.rs`, no other extension touched. `cargo check --workspace` exits 0 afterwards, so nothing changed semantically. ON THE ORDERING, WHICH WAS THE REAL QUESTION. HANDOFF-2026-09-06 section 7 warns this is the expensive fix: a whole-tree reformat before #7 and #8 return "would put a conflict in every file of 861 commits and make the reviews those items exist to enable unreadable". That is measurably too pessimistic, and it had been reasoned rather than tested. Measured here by three-way merging a rustfmt'd `main` against both unmerged branches, file by file: file/branch pairs tested 32 merges CLEAN 28 merges CONFLICTING 4 (8 conflict hunks total) sylpheed-cli/src/main.rs 1 hunk sylpheed-export/src/check.rs 1 sylpheed-export/src/screen.rs 4 sylpheed-export/src/video.rs 2 All four are against `auto/frame-blend-draw-path` only; `auto/port-p6-audio` does not conflict anywhere. The earlier framing -- 154 dirty files, 133 that cannot collide, 21 that can, the collision set carrying 147 of 774 hunks (19%) -- reproduces exactly. What it did not say is that most of the 21 still merge cleanly, because rustfmt's edits and the branches' edits rarely land on the same lines. So the cost of sweeping now is 4 files and 8 hunks for one branch, against a check that is otherwise red forever. Deliberately NOT folded into the WASM PR: 154 reformatted files would make that one unreviewable. Closes #12
140 lines
4.8 KiB
Rust
140 lines
4.8 KiB
Rust
//! Dump a UI screen's full layout from one RATC bundle: the element declaration
|
|
//! table (what is drawn, in back-to-front order, with pivots and parent links)
|
|
//! plus the placement region that follows it (per element: a keyframe group of
|
|
//! scale / tint / X / Y).
|
|
//!
|
|
//! See docs/re/structures/ui-rat-layout.md. Run:
|
|
//! cargo run -p sylpheed-formats --example screen_layout -- <PAK> [0xHASH]
|
|
//! With no hash, the largest RATC entry in the pak is used.
|
|
|
|
use sylpheed_formats::pak::PakArchive;
|
|
|
|
fn be32(b: &[u8], o: usize) -> u32 {
|
|
u32::from_be_bytes([b[o], b[o + 1], b[o + 2], b[o + 3]])
|
|
}
|
|
|
|
fn main() {
|
|
let mut args = std::env::args().skip(1);
|
|
let pak = args.next().expect("usage: screen_layout <pak> [0xHASH]");
|
|
let want = args.next();
|
|
let arc = PakArchive::open(&pak).expect("open pak");
|
|
|
|
let bytes = match want {
|
|
Some(h) if h.starts_with("0x") => {
|
|
let h = u32::from_str_radix(h.trim_start_matches("0x"), 16).expect("hash");
|
|
arc.read_by_hash(h).expect("entry").expect("decompress")
|
|
}
|
|
Some(name) => arc
|
|
.read_by_name(&name)
|
|
.expect("entry present")
|
|
.expect("decompress"),
|
|
None => arc
|
|
.entries()
|
|
.iter()
|
|
.filter_map(|e| arc.read(e).ok())
|
|
.filter(|b| b.len() > 16 && &b[..4] == b"RATC")
|
|
.max_by_key(|b| b.len())
|
|
.expect("no RATC entry"),
|
|
};
|
|
assert_eq!(&bytes[..4], b"RATC", "not a RATC bundle");
|
|
|
|
let count = be32(&bytes, 0x14) as usize;
|
|
let mut names = Vec::with_capacity(count);
|
|
let mut meta = Vec::with_capacity(count);
|
|
for i in 0..count {
|
|
let e = &bytes[0x20 + i * 60..0x20 + (i + 1) * 60];
|
|
let name = String::from_utf8_lossy(&e[..28])
|
|
.trim_end_matches('\0')
|
|
.trim_end_matches(char::from(0))
|
|
.to_string();
|
|
let parent = be32(e, 32);
|
|
let kind = be32(e, 40);
|
|
let (px, py) = (be32(e, 48), be32(e, 52));
|
|
names.push(name);
|
|
meta.push((parent, kind, px, py));
|
|
}
|
|
|
|
// Placement region: groups of (u32 element index, u32 keyframe count) then
|
|
// `count` 40-byte keyframes; the X/Y sit 12 bytes into the scale/tint block.
|
|
let mut pos = 0x20 + count * 60;
|
|
// X/Y are SIGNED: off-screen animation starts are negative (e.g. -516).
|
|
let mut placements: Vec<Vec<(i32, i32, u32)>> = vec![Vec::new(); count];
|
|
for _ in 0..count {
|
|
if pos + 8 > bytes.len() {
|
|
break;
|
|
}
|
|
let idx = be32(&bytes, pos) as usize;
|
|
let frames = be32(&bytes, pos + 4) as usize;
|
|
if idx >= count || frames == 0 || frames > 4096 {
|
|
break;
|
|
}
|
|
let first = pos + 28; // header + lead-in, verified on the pause bundles
|
|
let mut group = Vec::with_capacity(frames);
|
|
for k in 0..frames {
|
|
let blk = first + k * 40;
|
|
if blk + 20 > bytes.len() {
|
|
break;
|
|
}
|
|
group.push((
|
|
be32(&bytes, blk + 12) as i32,
|
|
be32(&bytes, blk + 16) as i32,
|
|
be32(&bytes, blk + 20),
|
|
));
|
|
}
|
|
placements[idx] = group;
|
|
pos = first + frames * 40 - 20;
|
|
}
|
|
|
|
println!("{} elements", count);
|
|
println!(
|
|
"{:<3} {:<30} {:>7} {:>8} {:>12} {:>4} placement",
|
|
"#", "element", "parent", "kind", "pivot", "kf"
|
|
);
|
|
for i in 0..count {
|
|
let (parent, kind, px, py) = meta[i];
|
|
let p = &placements[i];
|
|
// A group is an in → hold → out animation, so neither the first nor the
|
|
// last keyframe is where the element sits: report the MAX-DWELL one
|
|
// (longest gap to the next keyframe's time).
|
|
let shown = if p.is_empty() {
|
|
"—".into()
|
|
} else if p.len() == 1 {
|
|
format!("({},{})", p[0].0, p[0].1)
|
|
} else {
|
|
let mut best = (0usize, 0u32);
|
|
for k in 0..p.len() - 1 {
|
|
let d = p[k + 1].2.saturating_sub(p[k].2);
|
|
if d > best.1 {
|
|
best = (k, d)
|
|
}
|
|
}
|
|
let r = p[best.0];
|
|
format!(
|
|
"rest ({},{}) t={}..{} [{}]",
|
|
r.0,
|
|
r.1,
|
|
r.2,
|
|
p[best.0 + 1].2,
|
|
p.iter()
|
|
.map(|(x, y, t)| format!("{t}:{x},{y}"))
|
|
.collect::<Vec<_>>()
|
|
.join(" ")
|
|
)
|
|
};
|
|
println!(
|
|
"{:<3} {:<30} {:>7} {:>8} {:>12} {:>4} {}",
|
|
i,
|
|
names[i],
|
|
if parent == u32::MAX {
|
|
"-".into()
|
|
} else {
|
|
parent.to_string()
|
|
},
|
|
format!("{kind:#x}"),
|
|
format!("({px},{py})"),
|
|
p.len(),
|
|
shown
|
|
);
|
|
}
|
|
}
|