The core now loads the player's own `Interface\FrameXML\FrameXML.toc` off their chain, row by row in its order (`0x6edb90`, from `UI_Init` at `0x48ffed`), instead of benilla's copy of the list, and `benilla.toc` is gone. Order is observable in 1.12.1: event listeners run in registration order, children are kept in creation order, and hit-test ties go to the earlier frame. - The world VM starts bare: `GlobalStrings.lua` and `Fonts.xml` load as the toc's first rows. The boot VM keeps `GlobalStrings.lua` and the emote tokens, and no longer loads `Fonts.xml`, which nothing reads there (#307). - A chain without `FrameXML.toc` builds no stock UI and still loads the layer and addons, as the reference does (`"Couldn't open %s"`, severity 2, return unread); benilla reports it as an error. - Every test kit now loads in the production order, `FrameXML.toc`'s rows then `layer.toc`'s, and a guard fails any kit that loads out of it. Two tests whose premises the stock order disproves are gone. - `scripts/smoke.sh` counts VMs by the VM marker, since `Fonts.xml` now loads once per world VM. Verified: new tests for the load list against the chain toc and a reordered fixture toc, the missing-toc case, and two stock frames on one event running in the toc's order (ExhaustionTick before PlayerFrame on `PLAYER_UPDATE_RESTING`), each failing on main's order. A before/after dump of globals, frames, draw order, event listeners and saved variables differs only in stock-order effects: the reordered listeners and children, draw-order ties between non-overlapping frames, and `UnitPopup`'s quality colours now sharing the live tables. `scripts/gates.sh` and `scripts/smoke.sh` are green, and live before/after runs show 0 errors and identical warnings. Built on macOS; no platform seam touched. Fixes #555 Fixes #307 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
96 lines
3.6 KiB
Rust
96 lines
3.6 KiB
Rust
//! The shipped UI's files (`assets/ui`), compiled into the binary so the interface cannot be
|
|
//! missing; `load_ui_files` and its `<Include>` provider read them here, never through `std::fs`.
|
|
//! A dev build reads the source tree first, so an edit needs no recompile.
|
|
|
|
/// The shipped UI tree: `layer.toc` and every file of ours it names.
|
|
static UI: include_dir::Dir<'_> = include_dir::include_dir!("$CARGO_MANIFEST_DIR/assets/ui");
|
|
|
|
/// The text of one shipped UI file, by path relative to `assets/ui`; the basename fallback for a
|
|
/// FrameXML reference is the caller's.
|
|
pub(super) fn read(req: &str) -> Option<String> {
|
|
if let Some(text) = read_source_tree(req) {
|
|
return Some(text);
|
|
}
|
|
UI.get_file(req)?.contents_utf8().map(str::to_owned)
|
|
}
|
|
|
|
/// `assets/ui/<req>` on disk, or `None` in a player build, whose binary holds no source path.
|
|
fn read_source_tree(req: &str) -> Option<String> {
|
|
let dir = crate::run_mode::dev_source_dir()?.join("assets/ui");
|
|
std::fs::read_to_string(dir.join(req)).ok()
|
|
}
|
|
|
|
/// FNV-1a (not cryptographic) over the core's load list, then the layer's manifest and each file
|
|
/// it names when this run loads it, in load order, as eight hex digits: a stamp that tells two runs
|
|
/// whether they loaded the same interface. The core counts by its rows' names alone, in the toc's
|
|
/// order: their bytes are the player's install.
|
|
pub(crate) fn digest() -> String {
|
|
let mut h: u64 = 0xcbf2_9ce4_8422_2325;
|
|
let mut eat = |bytes: &[u8]| {
|
|
for b in bytes {
|
|
h ^= u64::from(*b);
|
|
h = h.wrapping_mul(0x1000_0000_01b3);
|
|
}
|
|
};
|
|
eat(super::reference_ui::TOC.as_bytes());
|
|
for name in super::reference_ui::core()
|
|
.map(|core| core.toc.files)
|
|
.unwrap_or_default()
|
|
{
|
|
eat(name.as_bytes());
|
|
}
|
|
if super::manifest::layer_enabled() {
|
|
let manifest = super::manifest::LAYER_MANIFEST;
|
|
eat(manifest.as_bytes());
|
|
if let Some(toc) = read(manifest) {
|
|
eat(toc.as_bytes());
|
|
}
|
|
for name in super::addons::Addon::layer().toc.files {
|
|
eat(name.as_bytes());
|
|
if let Some(text) = read(&name) {
|
|
eat(text.as_bytes());
|
|
}
|
|
}
|
|
}
|
|
format!("{:08x}", h as u32)
|
|
}
|
|
|
|
/// Every shipped file's path, relative to `assets/ui`, from the compiled-in set, not the disk.
|
|
#[cfg(test)]
|
|
pub(super) fn shipped_files() -> impl Iterator<Item = &'static str> {
|
|
UI.files().filter_map(|f| f.path().to_str())
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
#[test]
|
|
fn every_manifest_entry_is_compiled_in() {
|
|
for name in crate::ui_script::manifest::shipped_manifest_files() {
|
|
assert!(
|
|
super::read(&name).is_some(),
|
|
"a manifest names {name}, which is not in assets/ui"
|
|
);
|
|
}
|
|
}
|
|
|
|
/// A dev build prefers disk, so without this the two copies could disagree unnoticed.
|
|
#[test]
|
|
fn the_source_tree_and_the_compiled_in_copy_agree() {
|
|
// A player build has no source tree to disagree with.
|
|
let Some(dir) = crate::run_mode::dev_source_dir().map(|d| d.join("assets/ui")) else {
|
|
return;
|
|
};
|
|
let mut on_disk: Vec<String> = std::fs::read_dir(dir)
|
|
.unwrap()
|
|
.map(|e| e.unwrap().file_name().to_string_lossy().into_owned())
|
|
.collect();
|
|
let mut embedded: Vec<String> = super::shipped_files().map(str::to_owned).collect();
|
|
on_disk.sort();
|
|
embedded.sort();
|
|
assert_eq!(
|
|
on_disk, embedded,
|
|
"assets/ui on disk and the compiled-in copy disagree — rebuild, or one of them is stale"
|
|
);
|
|
}
|
|
}
|