Files

183 lines
8.3 KiB
Python

"""#112 (owner 2026-11-26: Edit Mode showed "addon blocked", Damage Done window could not be moved). Bisect on LOCAL:
WoWHybridUI NativeStatusBar.lua. Its fit of the bottom row (#81/#94/#103: right griffon past the backpack, XP/rep bars
from the action bar to the backpack, bars 2/3 centred and scaled between the griffon beaks) moved Edit Mode system
frames from addon code (SetPoint/SetScale/SetWidth), so Edit Mode's own secure layout later ran on tainted frames.
The same fit now lives in Blizzard's code:
- 7475645 camelot/editmodeutil.lua: EditModeUtil.FitOctoBottomRow (the addon's measurements, unchanged rules).
- 7110239 shared/editmodemanager.lua: UpdateBottomActionBarPositions calls it right after placing the default-position
bars, before ManageFramePositions. That pass already reruns on UI scale / display size changes, action bar grid
layout (actionbar.lua UpdateActionBarLayout) and status bar changes (EditModeManager.UpdateBottomActionBarPositions),
so every trigger the addon hooked is covered natively. Bars moved by the player in Edit Mode are left alone.
NativeStatusBar.lua is removed from WoWHybridUI with this step."""
import hashlib, json, struct, sys
from pathlib import Path
H = Path(__file__).resolve().parent; sys.path.insert(0, str(H))
import frozen_store as fs
md5 = lambda b: hashlib.md5(b).hexdigest(); sha = lambda b: hashlib.sha256(b).hexdigest()
crlf = lambda s: s.replace('\r\n', '\n').replace('\n', '\r\n').encode()
def once(old, a, b):
a, b = crlf(a), crlf(b); assert old.count(a) == 1, (a[:60], old.count(a)); return old.replace(a, b)
FIT = """
-- Octo (Turtle): the camelot bottom row here is split (no reagent slot, fewer micro buttons), so Blizzard's fixed
-- widths left the XP bar running past the bags and bars 2/3 under the griffon beaks. Fitted inside the bottom bar
-- layout pass, measured from the real frames so it follows UI scale and resolution:
-- the right griffon keeps the same gap past the backpack that the left griffon keeps from the action bar; the status
-- bars run from the action bar's left edge to the backpack's right edge; bars 2/3 (when at their default position)
-- form one row centred between the griffon beaks, just above the visible status bar, scaled down only if needed.
local OCTO_GAP = 2;
local OCTO_BEAK = 3;
local octoCapY;
local function OctoStatusShown(container)
if not container or not container:IsVisible() then
return false;
end
if type(container.bars) == "table" then
for _, bar in pairs(container.bars) do
if type(bar) == "table" and bar.IsShown and bar:IsShown() then
return true;
end
end
return false;
end
return true;
end
local function OctoFitTopBars(bar, s, capL, capR)
local top = MultiBarBottomLeft;
if not top or not top:IsShown() or not top:IsInDefaultPosition() then
return;
end
local function X(frame, edge) local v = frame[edge](frame); return v and v * frame:GetEffectiveScale() / s; end
local right = MultiBarBottomRight;
local joined = right and right:IsShown() and right:IsInDefaultPosition();
top:SetScale(1);
if joined then
right:SetScale(1);
end
local base = X(bar, "GetTop");
for _, container in ipairs({ MainStatusTrackingBarContainer, SecondaryStatusTrackingBarContainer }) do
if OctoStatusShown(container) then
local t = X(container, "GetTop");
if t and base and t > base then base = t; end
end
end
local l = X(bar, "GetLeft");
if not base or not l then
return;
end
local il, ir = capL and X(capL, "GetRight"), capR and X(capR, "GetLeft");
local function rowWidth()
local w = (top:GetWidth() or 0) * top:GetEffectiveScale() / s;
if joined then
w = w + (top.buttonPadding or OCTO_GAP) * top:GetEffectiveScale() / s + (right:GetWidth() or 0) * right:GetEffectiveScale() / s;
end
return w;
end
if il and ir then
local w, room = rowWidth(), ir - il - 2 * OCTO_BEAK;
if w > room and room > 0 then
top:SetScale(room / w);
if joined then right:SetScale(room / w); end
end
local w2 = rowWidth();
if w2 > 0 then l = math.max(il + OCTO_BEAK, il + (ir - il - w2) / 2); end
end
local k = s / top:GetEffectiveScale();
top:ClearAllPoints();
top:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", l * k, (base + OCTO_GAP) * k);
if joined then
right:ClearAllPoints();
right:SetPoint("BOTTOMLEFT", top, "BOTTOMRIGHT", (top.buttonPadding or OCTO_GAP) * top:GetEffectiveScale() / right:GetEffectiveScale(), 0);
end
end
function EditModeUtil.FitOctoBottomRow()
local bar = MainActionBar;
local caps = bar and bar.EndCaps;
local left, right = caps and caps.LeftEndCap, caps and caps.RightEndCap;
local bags = BagsBar;
if not bar or not left or not right or not bags or not bar:IsInDefaultPosition() or not bags:IsInDefaultPosition() then
return;
end
local s = bar:GetEffectiveScale();
local function X(frame, edge) local v = frame[edge](frame); return v and v * frame:GetEffectiveScale() / s; end
local l, lc, br = X(bar, "GetLeft"), X(left, "GetRight"), X(bags, "GetRight");
if not l or not lc or not br or not right:IsShown() then
return;
end
if not octoCapY then
local cb, bb = X(right, "GetBottom"), X(bags, "GetBottom");
if not cb or not bb then
return;
end
octoCapY = cb - bb;
end
local k = s / right:GetEffectiveScale();
right:ClearAllPoints();
right:SetPoint("BOTTOMLEFT", bags, "BOTTOMRIGHT", (l - lc) * k, octoCapY * k);
for _, container in ipairs({ MainStatusTrackingBarContainer, SecondaryStatusTrackingBarContainer }) do
if container and container.ResizeContainerBars and container:IsInDefaultPosition() then
local w = math.floor((br - l) * s / container:GetEffectiveScale() + 0.5);
if w > 100 and math.abs((container:GetWidth() or 0) - w) > 0.5 then
container:SetWidth(w);
container:ResizeContainerBars();
if container.UpdateDividers and container.GetExpectedSegments then
container:UpdateDividers(container:GetExpectedSegments());
end
end
end
end
OctoFitTopBars(bar, s, left, right);
end
"""
def util(old):
a = """function EditModeUtil.GetCenterManagedSystems()
return { MainActionBar, MicroMenu, BagsBar };
end
"""
return once(old, a, a + FIT)
def manager(old):
a = """ ManageFramePositions();
end
function EditModeManagerFrameMixin:UpdateTopFramePositions()
"""
return once(old, a, """ -- Octo (Turtle): fit the split camelot bottom row (see camelot EditModeUtil.FitOctoBottomRow).
if EditModeUtil.FitOctoBottomRow then
EditModeUtil.FitOctoBottomRow();
end
""" + a)
FILES = [(7475645, 'interface/addons/blizzard_editmode/camelot/editmodeutil.lua', util),
(7110239, 'interface/addons/blizzard_editmode/shared/editmodemanager.lua', manager)]
WHY = '#112: bottom-row fit (griffon, status bars, bars 2/3) inside the native Edit Mode layout pass instead of addon code'
store = fs.Store(); root = store.root; lay = store.layout; assert lay['root_md5'] == fs.ROOT
patched = bytearray(root); pins = []
for FID, NAME, edit in FILES:
cells = []
for g in lay['groups']:
f = 0
for i, (d,) in enumerate(struct.iter_unpack('<I', memoryview(root)[g['ids_offset']:g['ckeys_offset']])):
f += d
if f == FID: cells.append((g, g['ckeys_offset'] + i * 16))
f += 1
en = [(g, at) for g, at in cells if g['locale'] & 2 and not g.get('flags1')]; assert len(en) == 1, len(en)
g, at = en[0]; ck = root[at:at + 16].hex(); old = store.read(ck)[2]
new = edit(old)
(H / 'inputs').mkdir(exist_ok=True)
(H / 'inputs' / f'{FID}.before.lua').write_bytes(old); (H / 'inputs' / f'{FID}.after.lua').write_bytes(new)
patched[at:at + 16] = bytes.fromhex(md5(new))
d = H / 'pins' / str(FID); d.mkdir(parents=True, exist_ok=True)
(d / 'before.bin').write_bytes(old); (d / 'after.bin').write_bytes(new)
pin = dict(fdid=FID, table=NAME, parent_root=fs.ROOT, selected_group={}, original_decoded=dict(file='before.bin', md5=ck, sha256=sha(old)),
encrypted_original=False, after_decoded=dict(file='after.bin', md5=md5(new), sha256=sha(new)), reason=WHY)
(d / 'pin.json').write_text(json.dumps(pin, indent=1) + '\n')
pins.append(dict(file=str(d / 'pin.json'), sha256=sha((d / 'pin.json').read_bytes()), type='wdc_enus'))
print(FID, len(old), len(new))
(H / 'components.json').write_text(json.dumps(pins, indent=2) + '\n')
(H / 'selected-root.json').write_text(json.dumps(dict(parent_build=fs.BUILD, parent_root=fs.ROOT,
decoded_root_sha256=sha(bytes(patched)), parent_root_sha256=sha(root)), indent=2) + '\n')
print('pins', len(pins))