the map opens full screen again after an addon windowed it
- the world map opens full screen again on a character that once ran Cartographer's windowed map: a saved frame position or size outlives the addon only while the frame is movable or resizable (2193) - the layout cache gates both the write and the apply on `userPlaced AND (movable|resizable)`, the reference's four sites, where benilla had only the setter's (2193) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,16 @@
|
||||
//! The **layout cache** — the consumer `Frame::user_placed` never had.
|
||||
//!
|
||||
//! `SetUserPlaced` / the drag entries set the client's userPlaced bit (`frame+0xb4 & 0x1000`,
|
||||
//! [`super::object::movable`]), and its whole meaning is *"the player put this window here; put it
|
||||
//! back next time"*. The real client honours that by writing a per-character `layout-cache.txt` at
|
||||
//! logout and seating the frames from it at load; benilla had the bit and nothing that read it, so
|
||||
//! a dragged or resized window went back to its authored anchors on the next login.
|
||||
//! [`super::object::movable`]), and together with the frame's own `movable`/`resizable` flags it
|
||||
//! means *"the player put this window here; put it back next time"*. The real client honours that
|
||||
//! by writing a per-character `layout-cache.txt` at logout and seating the frames from it at load;
|
||||
//! benilla had the bit and nothing that read it, so a dragged or resized window went back to its
|
||||
//! authored anchors on the next login.
|
||||
//!
|
||||
//! **The bit is not the whole gate**, at either end — see [`super::UiScript::user_placed_layouts`]
|
||||
//! and [`super::UiScript::restore_user_placed_layouts`] for the conjuncts and their byte sites.
|
||||
//! Reading it as the whole gate is what let one addon's stamp seat a stock frame forever
|
||||
//! (decision 2193).
|
||||
//!
|
||||
//! This module is the **engine half** of that: a snapshot out, a restore in, and a dirty bit for
|
||||
//! the host to debounce on. Where the file lives, when it is written and which character owns it
|
||||
@@ -81,18 +87,30 @@ pub struct FrameLayout {
|
||||
}
|
||||
|
||||
impl super::UiScript {
|
||||
/// Snapshot every frame carrying the userPlaced bit — the save path.
|
||||
/// Snapshot every frame the reference's writer would write — the save path.
|
||||
///
|
||||
/// Sorted by name so the file is stable: a rewrite that reorders its own lines makes every
|
||||
/// diff useless and every "did this change?" check a false positive. Frames whose anchors
|
||||
/// cannot be re-addressed by name are dropped (see the module doc), as are unnamed ones —
|
||||
/// there is nothing to write them under.
|
||||
///
|
||||
/// **The filter is `userPlaced AND (movable OR resizable)`, not the bit alone.** The
|
||||
/// reference's per-frame writer `0x490e60` tests four conjuncts in a row: a non-NULL name
|
||||
/// (`0x490e79`), a non-empty one (`0x490e82`), `userPlaced` (`0x490e8e test ah,0x10` =
|
||||
/// `0x1000`) and **`movable|resizable`** (`0x490e97 test ah,0x3` = `0x100|0x200`). The bit
|
||||
/// alone was benilla's whole filter until decision 2193, and the missing fourth conjunct is
|
||||
/// what made this cache a one-way ratchet: **every** drag entry stamps `userPlaced`
|
||||
/// (`0x7652b0` @`0x7652e5`, with no cursor-movement dependency), so an addon that windows a
|
||||
/// stock frame and stamps it in passing — `Cartographer/Modules/LookNFeel.lua`'s
|
||||
/// `StartMoving(); StopMovingOrSizing()` over `WorldMapFrame` — wrote a row that outlived
|
||||
/// the addon on every character, forever. The reference drops that row at the first logout
|
||||
/// the addon does not load, because the frame's own `movable`/`resizable` flags went with it.
|
||||
pub fn user_placed_layouts(&self) -> Vec<FrameLayout> {
|
||||
let model = self.model_ref();
|
||||
let mut out: Vec<FrameLayout> = model
|
||||
.arena
|
||||
.iter_frames()
|
||||
.filter(|(_, f)| f.user_placed)
|
||||
.filter(|(_, f)| f.user_placed && (f.movable || f.resizable))
|
||||
.filter_map(|(h, f)| {
|
||||
let name = f.name.clone()?;
|
||||
let input = model.layout_inputs.get(&h)?;
|
||||
@@ -121,6 +139,18 @@ impl super::UiScript {
|
||||
/// the position: `UIParent_ManageFramePositions` skips a user-placed frame, so the managed
|
||||
/// bottom-stack pass does not re-seat the window the player moved.
|
||||
///
|
||||
/// **The apply is gated per ARM, not per row** (`0x4905e0`, decision 2193): the position arm
|
||||
/// is behind the frame's own `movable` bit (`0x490600 test ah,0x1`) and the size arm behind
|
||||
/// `resizable` (`0x490689 test ah,0x2`) — a frame carrying neither is left entirely alone,
|
||||
/// however old and however stamped its row is. The userPlaced stamp itself lives **inside**
|
||||
/// each arm (`0x49067e` in the position arm, `0x490706` in the size one), after that arm's
|
||||
/// own "the row carries no position" bail
|
||||
/// (`0x490613`, the reference's `X == 0 && Y == 0`; the size arm's twin is `0x49069a`'s
|
||||
/// `W == 0 && H == 0`). Both bails are spelled in this payload's own terms rather than the
|
||||
/// reference's integer sentinels: a row that carries no anchors, and a row that carries no
|
||||
/// size, are the same two states in a format that stores an anchor list instead of an X/Y
|
||||
/// pair.
|
||||
///
|
||||
/// It marks nothing dirty — the values came *from* the file, and an echo would re-dirty what
|
||||
/// was just read (`set_chat_window_looks`' reasoning, one store over).
|
||||
pub fn restore_user_placed_layouts(&mut self, layouts: impl IntoIterator<Item = FrameLayout>) {
|
||||
@@ -156,17 +186,37 @@ impl super::UiScript {
|
||||
if !usable {
|
||||
continue;
|
||||
}
|
||||
// The two arm gates, read before the layout input is borrowed mutably.
|
||||
let Some((movable, resizable)) = model.arena.frame(h).map(|f| (f.movable, f.resizable))
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
let seat_position = movable && !anchors.is_empty();
|
||||
let seat_size = resizable && (l.width != 0.0 || l.height != 0.0);
|
||||
if !seat_position && !seat_size {
|
||||
continue;
|
||||
}
|
||||
let Some(input) = model.layout_inputs.get_mut(&h) else {
|
||||
continue;
|
||||
};
|
||||
let changed = input.anchors != anchors
|
||||
|| input.width.to_bits() != l.width.to_bits()
|
||||
|| input.height.to_bits() != l.height.to_bits();
|
||||
input.anchors = anchors;
|
||||
input.width = l.width;
|
||||
input.height = l.height;
|
||||
if let Some(f) = model.arena.frame_mut(h) {
|
||||
f.user_placed = true;
|
||||
let mut changed = false;
|
||||
if seat_position {
|
||||
changed |= input.anchors != anchors;
|
||||
input.anchors = anchors;
|
||||
}
|
||||
if seat_size {
|
||||
changed |= input.width.to_bits() != l.width.to_bits()
|
||||
|| input.height.to_bits() != l.height.to_bits();
|
||||
input.width = l.width;
|
||||
input.height = l.height;
|
||||
}
|
||||
// The stamp is EACH arm's, not the row's: the position arm's is `0x49067e` and the
|
||||
// size arm's `0x490706`, both inside their own gate. A frame that took neither is
|
||||
// left un-stamped, which is what lets its row fall out of the file.
|
||||
if seat_position || seat_size {
|
||||
if let Some(f) = model.arena.frame_mut(h) {
|
||||
f.user_placed = true;
|
||||
}
|
||||
}
|
||||
if changed {
|
||||
// The whole graph, not the frame alone: a restore REPOINTS anchors (a saved row
|
||||
|
||||
@@ -615,3 +615,117 @@ fn region_getters_answer_in_the_owners_units_under_scale() {
|
||||
);
|
||||
assert!((cx - (fl + fr) * 0.5).abs() < 1e-3);
|
||||
}
|
||||
|
||||
/// **The layout cache's filter is the flags AND the bit, at both ends** (decision 2193).
|
||||
///
|
||||
/// `SetUserPlaced` is already guarded by `movable|resizable` at its own setter (`0x776adb`), but
|
||||
/// the drag entry (`0x7652b0` @`0x7652e5`) and the cache's own apply stamp the bit without going
|
||||
/// through it — so a frame can carry the stamp while carrying neither flag, and the reference's
|
||||
/// writer tests for both: `0x490e8e test ah,0x10` (userPlaced) AND `0x490e97 test ah,0x3`
|
||||
/// (`movable|resizable`). Clearing the flags is how a window stops being persisted, which is what
|
||||
/// an addon's `:OnDisable` does on the way out.
|
||||
#[test]
|
||||
fn the_write_filter_is_user_placed_and_movable_or_resizable() {
|
||||
let mut s = script();
|
||||
s.set_screen_size(800.0, 600.0);
|
||||
s.run(
|
||||
r#"
|
||||
F = CreateFrame("Frame", "CachePanel")
|
||||
F:SetPoint("BOTTOMLEFT", 10, 10); F:SetWidth(50); F:SetHeight(50)
|
||||
F:SetResizable(true); F:SetUserPlaced(true)
|
||||
"#,
|
||||
)
|
||||
.unwrap();
|
||||
let names = |s: &UiScript| {
|
||||
s.user_placed_layouts()
|
||||
.into_iter()
|
||||
.map(|l| l.name)
|
||||
.collect::<Vec<_>>()
|
||||
};
|
||||
assert_eq!(names(&s), ["CachePanel"], "stamped and resizable — written");
|
||||
|
||||
s.run("CachePanel:SetResizable(false)").unwrap();
|
||||
assert!(
|
||||
s.eval::<bool>("return CachePanel:IsUserPlaced()").unwrap(),
|
||||
"the stamp itself survives the flag going away — nothing clears it"
|
||||
);
|
||||
assert!(
|
||||
names(&s).is_empty(),
|
||||
"but the row does not: the fourth conjunct is gone"
|
||||
);
|
||||
|
||||
s.run("CachePanel:SetMovable(true)").unwrap();
|
||||
assert_eq!(names(&s), ["CachePanel"], "either flag satisfies it");
|
||||
assert!(s.errors().is_empty(), "{:?}", s.errors());
|
||||
}
|
||||
|
||||
/// **The apply is gated per ARM** (decision 2193): position behind `movable` (`0x490600 test
|
||||
/// ah,0x1`), size behind `resizable` (`0x490689 test ah,0x2`), and each arm stamps the userPlaced
|
||||
/// bit itself (`0x49067e` / `0x490706`) only if it ran. A stock frame carrying neither flag is
|
||||
/// left entirely alone, however old its row — which is what stops one addon's stamp from seating
|
||||
/// a window forever.
|
||||
#[test]
|
||||
fn the_apply_seats_position_behind_movable_and_size_behind_resizable() {
|
||||
use crate::script::{FrameLayout, LayoutPoint};
|
||||
|
||||
let row = |name: &str| FrameLayout {
|
||||
name: name.to_owned(),
|
||||
width: 200.0,
|
||||
height: 80.0,
|
||||
points: vec![LayoutPoint {
|
||||
point: "BOTTOMLEFT".into(),
|
||||
relative_to: None,
|
||||
relative_point: "BOTTOMLEFT".into(),
|
||||
x: 300.0,
|
||||
y: 200.0,
|
||||
}],
|
||||
};
|
||||
// Three frames, one per flag state, all authored identically.
|
||||
let mut s = script();
|
||||
s.set_screen_size(800.0, 600.0);
|
||||
for (name, flags) in [
|
||||
("Neither", ""),
|
||||
("Movable", "F:SetMovable(true)"),
|
||||
("Sizable", "F:SetResizable(true)"),
|
||||
] {
|
||||
s.run(&format!(
|
||||
r#"F = CreateFrame("Frame", "{name}")
|
||||
F:SetPoint("BOTTOMLEFT", 10, 10); F:SetWidth(50); F:SetHeight(50)
|
||||
{flags}"#
|
||||
))
|
||||
.unwrap();
|
||||
s.restore_user_placed_layouts([row(name)]);
|
||||
}
|
||||
s.resolve();
|
||||
let read = |s: &UiScript, n: &str| {
|
||||
s.eval::<(f64, f64, f64, bool)>(&format!(
|
||||
"local f = getglobal('{n}') \
|
||||
return f:GetLeft(), f:GetWidth(), f:GetHeight(), f:IsUserPlaced()"
|
||||
))
|
||||
.unwrap()
|
||||
};
|
||||
assert_eq!(
|
||||
read(&s, "Neither"),
|
||||
(10.0, 50.0, 50.0, false),
|
||||
"neither flag: the row is inert, and leaves no stamp behind either"
|
||||
);
|
||||
assert_eq!(
|
||||
read(&s, "Movable"),
|
||||
(300.0, 50.0, 50.0, true),
|
||||
"movable: seated at the saved position, still its authored size"
|
||||
);
|
||||
assert_eq!(
|
||||
read(&s, "Sizable"),
|
||||
(10.0, 200.0, 80.0, true),
|
||||
"resizable: given the saved size, left on its authored anchors"
|
||||
);
|
||||
assert_eq!(
|
||||
s.user_placed_layouts()
|
||||
.into_iter()
|
||||
.map(|l| l.name)
|
||||
.collect::<Vec<_>>(),
|
||||
["Movable", "Sizable"],
|
||||
"and only the two that took an arm are written back"
|
||||
);
|
||||
assert!(s.errors().is_empty(), "{:?}", s.errors());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user