fix(D.2b): correct edge-anchor mapping (RightEdge==1=stretch) + enable vitals horizontal resize
ToAnchors was inverted vs retail UIElement::UpdateForParentSizeChange @0x00462640: stretch is RightEdge==1 (not ==2/==4), LeftEdge==2 = track-right. Verified against all 19 vitals fixture pieces. Enables Resizable/ResizeX on the importer vitals root (the prior 'dat is fixed-size' conclusion was wrong). At-rest render unchanged (anchors only fire on resize). Added a 160->200 resize conformance test. Also fixed DatWidgetFactoryTests.RectAndAnchors_SetFromElementInfo which encoded the old inverted model (Right=2 expecting Right anchor; corrected to Right=1). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
825536a2bd
commit
8aa643f3e0
6 changed files with 174 additions and 105 deletions
|
|
@ -139,38 +139,40 @@ These are `uint` fields on `ElementDesc`. The values found across all four vital
|
|||
| Value | Meaning | Where observed |
|
||||
|-------|---------|---------------|
|
||||
| `0` | Not present / no constraint | Base layout `0x2100003F` (zero-size elements) |
|
||||
| `1` | **Pinned to near edge** (left for LeftEdge, top for TopEdge) | Everywhere in vitals |
|
||||
| `2` | **Pinned to far edge** (right for LeftEdge, bottom for TopEdge) | Corners/bottom elements |
|
||||
| `3` | **Centered / pinned to both far edges** (floated, centered between two sides) | The expand-detail overlay child `0x100004A9` |
|
||||
| `4` | **Stretch / pinned to BOTH sides** | Meter elements in `0x21000014`/`0x21000075`; means the element stretches with parent resize |
|
||||
| `1` | **Stretch / track-far** — for LeftEdge: pin left (near); for RightEdge: stretch (track parent's right edge); for TopEdge: pin top; for BottomEdge: stretch (track parent's bottom) | Most vitals pieces |
|
||||
| `2` | **Track-right (for LeftEdge) / fixed-far (for RightEdge)** — LeftEdge=2 means the element's LEFT side tracks the parent's RIGHT edge (fixed-width piece that moves right); RightEdge=2 means the right edge is fixed relative to the parent right (no stretch) | Corners/right-side pieces |
|
||||
| `3` | **Centered / floating** — contributes no anchor on that axis | The expand-detail overlay child `0x100004A9` |
|
||||
| `4` | **Both-sides** — both near AND far edges fire simultaneously | Seen in child layout meter elements |
|
||||
|
||||
### Anchor logic (correcting the plan's assumption)
|
||||
### Anchor logic (retail-faithful, per `UIElement::UpdateForParentSizeChange @0x00462640`)
|
||||
|
||||
**The plan assumed value `4` = "pinned to that side."** The correct semantics are:
|
||||
The **far-axis fields** (RightEdge, BottomEdge) drive stretch:
|
||||
- **RightEdge==1** ⇒ the right edge tracks the parent's right edge (**STRETCH**; designRight+delta)
|
||||
- **RightEdge==2** ⇒ designRight is fixed (no stretch)
|
||||
- **LeftEdge==2** ⇒ a fixed-width piece's left side tracks the parent's right edge (it **moves right**)
|
||||
- **LeftEdge==1** ⇒ pin left at designX (near-pin)
|
||||
- **value==4** ⇒ both near AND far fire simultaneously (stretch + keep near)
|
||||
- **value==3** ⇒ centered / floating (no anchor on that axis)
|
||||
- **value==0** ⇒ no anchor (prototype-only)
|
||||
|
||||
- `1` = pinned to the **near** edge of that axis (left, or top)
|
||||
- `2` = pinned to the **far** edge (right, or bottom)
|
||||
- `3` = pinned to BOTH far edges (centered/floating between the two anchors on that axis)
|
||||
- `4` = stretch anchor: pinned to BOTH the near AND far edges simultaneously (element stretches)
|
||||
- `0` = no anchor (zero-size elements used as font/style prototypes in the base layout)
|
||||
This is the INVERSE of the earlier §Corrections reading ("1=near, 2=far"), which was wrong. The decomp is authoritative: `UIElement::UpdateForParentSizeChange @0x00462640` in `docs/research/named-retail/acclient_2013_pseudo_c.txt` lines 108459–108668.
|
||||
|
||||
Evidence from the `0x21000014` dump: the health meter (`0x100000E6`) has `LeftEdge=1, RightEdge=4` meaning "pin left edge, stretch right" — the meter fills from the left to the window's right edge. The stamina meter (`0x100000EC`) has `LeftEdge=4, RightEdge=4` meaning it stretches on both sides (centered at 270px, fills width with parent).
|
||||
|
||||
**Revised `ToAnchors` logic:**
|
||||
**Correct `ToAnchors` logic (as implemented in `ElementReader.cs`):**
|
||||
```csharp
|
||||
// Per UIElement::UpdateForParentSizeChange @0x00462640
|
||||
public static AnchorEdges ToAnchors(uint left, uint top, uint right, uint bottom)
|
||||
{
|
||||
// 1 = near-pin, 2 = far-pin, 3 = both-far (floating center), 4 = stretch (both sides)
|
||||
var a = AnchorEdges.None;
|
||||
if (left == 1 || left == 4) a |= AnchorEdges.Left;
|
||||
if (top == 1 || top == 4) a |= AnchorEdges.Top;
|
||||
if (right == 2 || right == 4) a |= AnchorEdges.Right;
|
||||
if (bottom == 2 || bottom == 4) a |= AnchorEdges.Bottom;
|
||||
if (left == 1 || left == 4) a |= AnchorEdges.Left;
|
||||
if (right == 1 || right == 4 || left == 2) a |= AnchorEdges.Right;
|
||||
if (top == 1 || top == 4) a |= AnchorEdges.Top;
|
||||
if (bottom == 1 || bottom == 4 || top == 2) a |= AnchorEdges.Bottom;
|
||||
if (a == AnchorEdges.None) a = AnchorEdges.Left | AnchorEdges.Top; // default: pin top-left
|
||||
return a;
|
||||
}
|
||||
```
|
||||
Value `3` (floating center) is a "pin far but not near" on both axes — maps to Right+Bottom anchors but NOT Left+Top. This shows up only on the hide/show-detail overlay child (`0x100004A9`) which is visually centered in the bar.
|
||||
|
||||
**Verified against all 19 vitals pieces** (format doc §11). At-rest render (no resize) is pixel-identical — anchors only fire on resize. Value `3` contributes no anchor on its axis and falls through to the Left|Top default only when all four values are 3 or 0.
|
||||
|
||||
---
|
||||
|
||||
|
|
@ -407,28 +409,31 @@ Each meter has:
|
|||
|
||||
## § Corrections to plan assumptions
|
||||
|
||||
### 1. Edge-flag "pinned" value is NOT simply `4`
|
||||
### 1. Edge-flag semantics are INVERTED from the earlier §4 reading
|
||||
|
||||
**Plan assumed:** `if (left == 4) a |= AnchorEdges.Left;`
|
||||
**Correct semantics:**
|
||||
**Original §4 reading (Task 2 shipped):** `1=near, 2=far, 4=stretch` → `right==2||right==4` for Right anchor.
|
||||
**That was wrong.** The correct semantics, per `UIElement::UpdateForParentSizeChange @0x00462640`:
|
||||
|
||||
| Edge value | Meaning |
|
||||
|-----------|---------|
|
||||
| 0 | no anchor (prototype-only elements) |
|
||||
| 1 | pinned to **near** edge (left/top) |
|
||||
| 2 | pinned to **far** edge (right/bottom) |
|
||||
| 3 | pinned to BOTH far edges (centered/floating) |
|
||||
| 4 | stretch: pinned to BOTH near AND far edges simultaneously |
|
||||
| Edge value | LeftEdge meaning | RightEdge meaning |
|
||||
|-----------|-----------------|------------------|
|
||||
| 0 | no anchor | no anchor |
|
||||
| 1 | pin left (near) → **Left** | track parent's right edge (stretch) → **Right** |
|
||||
| 2 | track parent's right edge (moves right) → **Right** | fixed right (no stretch) |
|
||||
| 3 | centered / floating (no anchor) | centered / floating (no anchor) |
|
||||
| 4 | both-sides → **Left + Right** | both-sides → **Left + Right** |
|
||||
|
||||
**Fix for Task 2:**
|
||||
The far-axis field (RightEdge, BottomEdge) value `1` means **stretch** (track the parent's far edge), NOT "near-pin." This is the INVERSE of what was documented in the original §4.
|
||||
|
||||
**Correct `ToAnchors` (as fixed in `ElementReader.cs` 2026-06-15):**
|
||||
```csharp
|
||||
// Per UIElement::UpdateForParentSizeChange @0x00462640
|
||||
public static AnchorEdges ToAnchors(uint left, uint top, uint right, uint bottom)
|
||||
{
|
||||
var a = AnchorEdges.None;
|
||||
if (left == 1 || left == 4) a |= AnchorEdges.Left;
|
||||
if (top == 1 || top == 4) a |= AnchorEdges.Top;
|
||||
if (right == 2 || right == 4) a |= AnchorEdges.Right;
|
||||
if (bottom == 2 || bottom == 4) a |= AnchorEdges.Bottom;
|
||||
if (left == 1 || left == 4) a |= AnchorEdges.Left;
|
||||
if (right == 1 || right == 4 || left == 2) a |= AnchorEdges.Right;
|
||||
if (top == 1 || top == 4) a |= AnchorEdges.Top;
|
||||
if (bottom == 1 || bottom == 4 || top == 2) a |= AnchorEdges.Bottom;
|
||||
if (a == AnchorEdges.None) a = AnchorEdges.Left | AnchorEdges.Top;
|
||||
return a;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue