The port needed ptbtneff01.t32's placement and was about to author it from an eyeballed PNG measurement. It does not have to: a `.rat` leaf needs no new reader. Its first 32 bytes have a bundle header's shape -- "RATC", 0x3c declaration-entry size at +4, element count at +20, design 1280x720 at +24/+28 -- so ui_layout::parse_build reads it unchanged. The control is the base record, whose position is known independently: the parent screen reports ptbtn01.rat resting at (542,162), and parsing the leaf alone returns ptbtn01.t32 at (542,162). It reproduces all five buttons. Positions are absolute design-space top-left. The ring rests at (500, 156/236/ 316/396/476) for buttons 1-5 -- a uniform (-42,-6) from each button's own rest, identical in the Japanese bundle. The bright label is a uniform (-7,-7). Two things recorded rather than smoothed over: a leaf's placement DUPLICATES the parent's rather than being relative to it, and the two copies are not always byte-equal (ptbtn04's parent says y=401, its leaf says 402) -- the parent is what compose honours, so the leaf is the source only for elements the parent does not declare, which is exactly the ring. And `screen render --focus` is blind to the ring for the same reason the port's exporter was: el.focused is name-based on top-level elements and neither walks into the leaf.
65 lines
2.7 KiB
Rust
65 lines
2.7 KiB
Rust
//! Does a `.rat` leaf record decode with the same reader as a whole bundle?
|
|
//!
|
|
//! The port needs the position of `ptbtneff01.t32`, the focus ring, which is
|
|
//! declared *inside* the nested `ptbtn0Nf.rat` leaf and is therefore invisible
|
|
//! to anything that walks only a bundle's top-level elements.
|
|
//!
|
|
//! The leaf's first 32 bytes have the same shape as a bundle header --
|
|
//! `"RATC"`, `0x3c` declaration-entry size at `+4`, element count at `+20`,
|
|
//! design size at `+24`/`+28` -- so the hypothesis is that `parse_build` reads
|
|
//! it unchanged. The control is the BASE record `ptbtn0N.rat`, whose single
|
|
//! element's position is already known independently: the parent screen's
|
|
//! `screen info` reports `ptbtn01.rat` resting at (542,162).
|
|
//!
|
|
//! cargo run -p sylpheed-formats --example rat_leaf_placement -- <GP_TITLE.pak>
|
|
use sylpheed_formats::{pak, ratc, ui_layout};
|
|
|
|
fn main() {
|
|
let path = std::env::args().nth(1).expect("usage: … <pak>");
|
|
let ar = pak::PakArchive::open(&path).expect("open pak");
|
|
let entries: Vec<_> = ar.entries().to_vec();
|
|
|
|
for (ei, e) in entries.iter().enumerate() {
|
|
let Ok(bytes) = ar.read(e) else { continue };
|
|
let Some(kids) = ratc::parse(&bytes) else { continue };
|
|
// Only the title-family bundles carry ptbtn records.
|
|
if !kids.iter().any(|c| c.name == "ptbtn01f.rat") {
|
|
continue;
|
|
}
|
|
println!("=== pak entry {ei}");
|
|
for c in &kids {
|
|
if c.kind != "RATC" || !c.name.starts_with("ptbtn") {
|
|
continue;
|
|
}
|
|
let leaf = &bytes[c.offset..c.offset + c.size];
|
|
match ui_layout::parse_build(leaf) {
|
|
None => println!(" {:16} …parse_build says no", c.name),
|
|
Some(b) => {
|
|
println!(
|
|
" {:16} {}x{} {} element(s), fallback={}",
|
|
c.name,
|
|
b.design_w,
|
|
b.design_h,
|
|
b.elements.len(),
|
|
b.from_fallback
|
|
);
|
|
for el in &b.elements {
|
|
let r = el.rest();
|
|
println!(
|
|
" [{}] {:18} pivot ({:4},{:4}) rest ({:5},{:5}) kf {}",
|
|
el.index,
|
|
el.name,
|
|
el.pivot_x,
|
|
el.pivot_y,
|
|
r.map(|k| k.x).unwrap_or(-1),
|
|
r.map(|k| k.y).unwrap_or(-1),
|
|
el.keyframes.len()
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
println!();
|
|
}
|
|
}
|