This branch predates CI on `main`. `cargo fmt --all` only; no behaviour. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
46 lines
1.8 KiB
Rust
46 lines
1.8 KiB
Rust
//! Dump the keyframes of any nested `.rat` leaf by name.
|
|
//!
|
|
//! cargo run -p sylpheed-formats --example leaf_keyframes -- GP_TITLE ptbtn00.rat 2 3 4
|
|
use std::path::PathBuf;
|
|
use sylpheed_formats::{pak::PakArchive, ui_layout};
|
|
|
|
fn main() {
|
|
let root = PathBuf::from(std::env::var("SYLPHEED_DISC").expect("SYLPHEED_DISC"));
|
|
let argv: Vec<String> = std::env::args().skip(1).collect();
|
|
let pak = argv[0].clone();
|
|
let rec = argv[1].clone();
|
|
let builds: Vec<usize> = argv[2..].iter().filter_map(|a| a.parse().ok()).collect();
|
|
let ar = PakArchive::open(root.join(format!("dat/{pak}.pak"))).expect("pak");
|
|
for e in builds {
|
|
let Ok(by) = ar.read(&ar.entries()[e]) else {
|
|
continue;
|
|
};
|
|
let Some(b) = ui_layout::parse_build(&by) else {
|
|
continue;
|
|
};
|
|
let Some(&(lo, ls)) = b.records.get(rec.as_str()) else {
|
|
continue;
|
|
};
|
|
let leaf = &by[lo..(lo + ls).min(by.len())];
|
|
println!("=== {pak} entry {e} — {rec} (leaf {ls} bytes) ===");
|
|
if let Some(u) = ui_layout::loop_length_units(leaf) {
|
|
println!(" declared loop: {u} units");
|
|
}
|
|
if let Some(lb) = ui_layout::parse_build(leaf) {
|
|
for el in &lb.elements {
|
|
println!(" {} — {} keyframes", el.name, el.keyframes.len());
|
|
for (i, k) in el.keyframes.iter().enumerate() {
|
|
println!(
|
|
" kf{i:<2} t={:<5} x={:<6} y={:<6} fade={:08X} (alpha {:3})",
|
|
k.time.map(|t| t.to_string()).unwrap_or_else(|| "-".into()),
|
|
k.x,
|
|
k.y,
|
|
k.fade,
|
|
k.fade >> 24
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|