48 lines
2.8 KiB
Python
48 lines
2.8 KiB
Python
"""#105/#113: the third primary-profession spell button is Blizzard's own (content d6e928ae); WoWHybridUI never
|
|
creates book controls (an addon-written spellButtons[3] tainted every FormatProfession and blocked spell clicks)."""
|
|
from pathlib import Path
|
|
import re, subprocess
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
STEP = ROOT / 'ops/content-profbook3-20261126'
|
|
|
|
# Native template: the primary card's spellButtons array holds three ProfessionButtonTemplate buttons.
|
|
xml = (STEP / '7580732.after.xml').read_bytes().decode().replace('\r\n', '\n')
|
|
primary = xml[xml.index('<Frame name="PrimaryProfessionTemplate"'):xml.index('<Frame name="SecondaryProfessionTemplate"')]
|
|
buttons = re.findall(r'<CheckButton inherits="ProfessionButtonTemplate" parentKey="(SpellButton\d)" parentArray="spellButtons">', primary)
|
|
assert buttons == ['SpellButton1', 'SpellButton2', 'SpellButton3'], buttons
|
|
third = primary[primary.index('parentKey="SpellButton3"'):]
|
|
third = third[:third.index('</CheckButton>')]
|
|
assert 'doNotCloseParentUI' in third and 'x="190" y="10"' in third
|
|
|
|
# Native formatter: masks the third button like the others; the existing loop shows it only when numSpells >= 3.
|
|
book = (STEP / '7580731.after.lua').read_bytes().decode().replace('\r\n', '\n')
|
|
assert 'if frame.SpellButton3 then\n\t\tframe.SpellButton3.OutlineMask:Show();' in book
|
|
assert 'frame.spellButtons[spellButtonID]:SetShown(spellButtonID <= numSpells);' in book
|
|
|
|
lua = r'''
|
|
local callbacks, hooks, created = {}, {}, 0
|
|
function GetProfessions() return 1, nil end
|
|
function GetProfessionInfo() return 'Blacksmithing', nil, 1, 300, 3 end
|
|
function InCombatLockdown() return false end
|
|
function CreateFrame(kind)
|
|
if kind == 'CheckButton' then created = created + 1 end
|
|
local e = {}; function e:RegisterEvent() end; function e:UnregisterEvent() end
|
|
function e:SetScript(_, f) callbacks[#callbacks + 1] = f end
|
|
function e:HookScript() end
|
|
return e
|
|
end
|
|
function hooksecurefunc(owner, method, fn) hooks[#hooks + 1] = {owner = owner, method = method, fn = fn} end
|
|
local format = function() end
|
|
dofile(arg[1])
|
|
ProfessionsBookFrameMixin = {OnLoad = function() end, FormatProfession = format}
|
|
callbacks[1](nil, 'ADDON_LOADED'); assert(WoWHybridUI.professionBookInstalled)
|
|
assert(ProfessionsBookFrameMixin.FormatProfession == format)
|
|
local function card() return {spellButtons = {{}, {}, {}}} end
|
|
local page = {ProfessionsContentFrame = {PrimaryProfession1 = card(), PrimaryProfession2 = card()}}
|
|
pcall(hooks[1].fn, page)
|
|
assert(created == 0, 'addon must not create profession book buttons')
|
|
assert(#page.ProfessionsContentFrame.PrimaryProfession1.spellButtons == 3)
|
|
'''
|
|
subprocess.run(['lua', '-', str(ROOT / 'client_addons/WoWHybridUI/NativeProfessionsBook.lua')], input=lua.encode(), check=True)
|
|
print('Native third profession button in Blizzard template; addon creates no book controls PASS.')
|