This branch predates CI on `main`. `cargo fmt --all` only; no behaviour. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
49 lines
1.9 KiB
Rust
49 lines
1.9 KiB
Rust
//! Is `ptbtn11` the TOP item of the `EXTRAS` screen?
|
|
//!
|
|
//! `sylpheed-port` authors `extras/initial_focus: ptbtn11` and states it is
|
|
//! correct under the surviving reading — "a submenu resets to the item it opens
|
|
//! on". The oracle shows EXTRAS opening on `MISSION SELECT`, the first of
|
|
//! MISSION SELECT / MOVIE THEATER / BACK. So their value is right only if
|
|
//! `ptbtn11` is that first item. This checks it against the disc.
|
|
//!
|
|
//! CONTROL: the same read on the MAIN MENU build, whose five buttons have a known
|
|
//! top-to-bottom order (NEW GAME first). If the ordering rule cannot reproduce a
|
|
//! known screen it cannot be trusted on an unknown one.
|
|
//!
|
|
//! cargo run -p sylpheed-formats --example extras_button_order
|
|
use std::path::PathBuf;
|
|
use sylpheed_formats::{pak::PakArchive, ui_layout};
|
|
|
|
fn report(ar: &PakArchive, entry: usize, what: &str) {
|
|
let Ok(by) = ar.read(&ar.entries()[entry]) else {
|
|
return;
|
|
};
|
|
let Some(b) = ui_layout::parse_build(&by) else {
|
|
return;
|
|
};
|
|
let mut rows: Vec<(i32, String, u32)> = b
|
|
.elements
|
|
.iter()
|
|
.filter(|e| e.name.starts_with("ptbtn") && !e.name.contains('f'))
|
|
.map(|e| {
|
|
let y = e.rest().map(|k| k.y).unwrap_or(e.pivot_y as i32);
|
|
(y, e.name.clone(), e.kind)
|
|
})
|
|
.collect();
|
|
rows.sort_by_key(|r| r.0);
|
|
println!("\n{what} (entry {entry}) — buttons top to bottom:");
|
|
for (y, n, k) in &rows {
|
|
println!(" y {y:5} {n:14} kind 0x{k:04x}");
|
|
}
|
|
if let Some((_, first, _)) = rows.first() {
|
|
println!(" => TOP item is {first}");
|
|
}
|
|
}
|
|
|
|
fn main() {
|
|
let root = PathBuf::from(std::env::var("SYLPHEED_DISC").expect("SYLPHEED_DISC"));
|
|
let ar = PakArchive::open(root.join("dat/GP_TITLE.pak")).expect("GP_TITLE.pak");
|
|
report(&ar, 5, "CONTROL: main menu (NEW GAME must be top)");
|
|
report(&ar, 6, "EXTRAS");
|
|
}
|