43 lines
2.5 KiB
Python
43 lines
2.5 KiB
Python
"""Turtle has single-part names: in-game Lua treats RegionalUniqueNamesEnabled() as false; whisper tab key/target trimmed."""
|
|
import sys,struct,re
|
|
from pathlib import Path
|
|
H=Path(__file__).resolve().parent;sys.path.insert(0,str(H))
|
|
import frozen_store as fs
|
|
st=fs.Store();root=st.root;lay=st.layout
|
|
def get(fid):
|
|
out=[]
|
|
for g in lay['groups']:
|
|
if not g['locale']&2 or g.get('flags1'):continue
|
|
f=0
|
|
for i,(d,) in enumerate(struct.iter_unpack('<I',memoryview(root)[g['ids_offset']:g['ckeys_offset']])):
|
|
f+=d
|
|
if f==fid:out.append(root[g['ckeys_offset']+i*16:g['ckeys_offset']+i*16+16].hex())
|
|
f+=1
|
|
assert len(out)==1,(fid,out);return st.read(out[0])[2]
|
|
FLAG={5612423:'interface/addons/blizzard_unitpopup/mainline/unitpopuputils.lua',
|
|
5612498:'interface/addons/blizzard_unitpopupshared/unitpopupsharedbuttonmixins.lua',
|
|
5613466:'interface/addons/blizzard_unitpopupshared/unitpopupshared.lua',
|
|
7208180:'interface/addons/blizzard_chatframebase/shared/chatframeeditbox.lua',
|
|
7150906:'interface/addons/blizzard_chatframebase/shared/slashcommands.lua',
|
|
7406654:'interface/addons/blizzard_settingsdefinitions_frame/nameplates.lua',
|
|
7322753:'interface/addons/blizzard_recentallies/blizzard_recentalliesutil.lua',
|
|
7557116:'interface/addons/blizzard_unitframe/mainline/unitframe.lua',
|
|
7949501:'interface/addons/blizzard_framexmlutil/nameutil.lua',
|
|
7949502:'interface/addons/blizzard_framexmlutil/camelot/nameutil.lua',
|
|
7957699:'interface/addons/blizzard_friendsframe/mainline/friendslisttemplates.lua'}
|
|
FLOAT=(5613179,'interface/addons/blizzard_chatframebase/mainline/floatingchatframe.lua')
|
|
rows=[]
|
|
for fid,name in FLAG.items():
|
|
old=get(fid);n=old.count(b'RegionalUniqueNamesEnabled()')
|
|
new=re.sub(rb'(?<![\w.])RegionalUniqueNamesEnabled\(\)',b'false --[[Turtle single-part names]]',old)
|
|
assert n>=1 and new.count(b'Turtle single-part names')==n,(fid,n)
|
|
rows.append((fid,name,old,new))
|
|
fid,name=FLOAT;old=get(fid)
|
|
a=b'\t\t\tchatTarget = strupper(playerTarget);';b=b'\t\t\tchatTarget = strupper(strtrim(playerTarget));'
|
|
c=b'\t\t\tlocal chatTarget = tostring(select(2, ...));';d=b'\t\t\tlocal chatTarget = strtrim(tostring(select(2, ...)));'
|
|
assert old.count(a)==1 and old.count(c)==1,(old.count(a),old.count(c))
|
|
rows.append((fid,name,old,old.replace(a,b).replace(c,d)))
|
|
for fid,name,old,new in rows:
|
|
(H/'inputs'/f'{fid}.before.lua').write_bytes(old);(H/'inputs'/f'{fid}.after.lua').write_bytes(new)
|
|
print(fid,len(old),len(new),name)
|