72 lines
4.2 KiB
Python
72 lines
4.2 KiB
Python
"""#113/#105 (owner 2026-11-26: "add them all properly"): Turtle master smiths know 3 Blacksmithing book spells
|
|
(Artisan 9785, Weaponsmith 9787, Master Sword/Hammer/Axesmith 17039-17041; the server keeps the whole chain known), but the
|
|
camelot PrimaryProfessionTemplate has 2 spell buttons and FormatProfession asserts on more. The third button used to be
|
|
added by WoWHybridUI (NativeProfessionsBook.lua), which tainted the book (spell clicks blocked).
|
|
Now native:
|
|
- 7580732 camelot/blizzard_professionsbooktemplates.xml: SpellButton3 in PrimaryProfessionTemplate (parentArray
|
|
spellButtons, same ProfessionButtonTemplate), bottom-left at x=190 (under the rank bar, right of SpellButton2).
|
|
- 7580731 camelot/blizzard_professionsbook.lua: FormatProfession shows its outline mask like the other two; the
|
|
existing spellButtons loop shows/hides it per numSpells, so every other profession is unchanged."""
|
|
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)
|
|
BTN3 = """ <CheckButton inherits="ProfessionButtonTemplate" parentKey="SpellButton3" parentArray="spellButtons">
|
|
<KeyValues>
|
|
<KeyValue key="doNotCloseParentUI" value="true" type="boolean"/>
|
|
</KeyValues>
|
|
<Anchors>
|
|
<Anchor point="BOTTOMLEFT" relativePoint="BOTTOMLEFT" x="190" y="10" />
|
|
</Anchors>
|
|
</CheckButton>
|
|
"""
|
|
def templates(old):
|
|
a = """ <Anchor point="BOTTOMLEFT" relativeKey="$parent.SpellButton1" relativePoint="TOPLEFT"/>
|
|
</Anchors>
|
|
</CheckButton>
|
|
<Frame parentKey="StatusBar" frameStrata="HIGH" inherits="ProfessionsRankBarTemplate">
|
|
"""
|
|
head, tail = a.split(' <Frame parentKey="StatusBar"')
|
|
return once(old, a, head + BTN3 + ' <Frame parentKey="StatusBar"' + tail)
|
|
def book(old):
|
|
a = """ frame.SpellButton2.OutlineMask:Show();
|
|
"""
|
|
return once(old, a, a + """ if frame.SpellButton3 then
|
|
frame.SpellButton3.OutlineMask:Show();
|
|
end
|
|
""")
|
|
FILES = [(7580732, 'interface/addons/blizzard_professionsbook/camelot/blizzard_professionsbooktemplates.xml', templates),
|
|
(7580731, 'interface/addons/blizzard_professionsbook/camelot/blizzard_professionsbook.lua', book)]
|
|
WHY = '#113: native third primary-profession spell button (Turtle master smiths have 3 book spells)'
|
|
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))
|