Files
WoW-Hybrid-gateway/ops/native_nameplate_binding.py
praxisandClaude Fable 5.2 8a24c445b0 Content pipeline and operator tools
367 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

46 lines
3.7 KiB
Python

#!/usr/bin/env python3
"""Install a removable original-UI control adapter into the private client only.
The source-backed XML override experiment was inactive, even after restart;
its files and hashes remain in recovery/native-nameplate-binding/experiment.
This ordinary addon posthooks original player-setting, book, stat and icon controls.
"""
import argparse,datetime,hashlib,json,shutil,subprocess
from pathlib import Path
ROOT=Path(__file__).resolve().parents[1]
SOURCE=ROOT/'client_addons/WoWHybridUI'
TARGET=ROOT/'runtime/native-client/_classic_beta_/Interface/AddOns/WoWHybridUI'
JOURNAL=ROOT/'runtime/native-nameplate-ui-install.json'
def digest(b):return hashlib.sha256(b).hexdigest()
def install():
files={p.name:p.read_bytes() for p in SOURCE.iterdir() if p.is_file()}
if set(files)!={'NativeNameplates.lua','NativeProfessionsBook.lua','NativeCharacterStats.lua','NativeProfessionBorderData.lua','NativeProfessionIcons.lua','NativeEquipmentVisibility.lua','WoWHybridUI.toc'}:raise RuntimeError('Unexpected source UI module files')
for name,data in files.items():
if name.endswith('.lua'):subprocess.run(['luac','-p','-'],input=data,check=True)
if TARGET.is_symlink():raise RuntimeError('Unrelated addon link preserved')
if TARGET.exists():
if not JOURNAL.exists():raise RuntimeError('Existing unowned addon preserved')
previous=json.loads(JOURNAL.read_text())
actual={p.name:digest(p.read_bytes()) for p in TARGET.iterdir() if p.is_file()}
if actual!=previous['files'] or any(not p.is_file() for p in TARGET.iterdir()):raise RuntimeError('Installed UI module differs; preserve and review')
stamp=datetime.datetime.now(datetime.timezone.utc).strftime('%Y%m%dT%H%M%S.%fZ');recovery=ROOT/'recovery'/('native-nameplate-ui-'+stamp);recovery.mkdir(mode=0o700)
if TARGET.exists():
shutil.copytree(TARGET,recovery/'previous-addon')
shutil.copy2(JOURNAL,recovery/'previous-manifest.json')
# Retire only the hash-owned inactive XML candidate, preserving its bytes.
old_journal=ROOT/'runtime/native-nameplate-binding-patch.json'
if old_journal.exists():
old=json.loads(old_journal.read_text());xml=ROOT/old['target']
expected=ROOT/'runtime/native-client/_classic_beta_/Interface/AddOns/Blizzard_FrameXML/Bindings_Camelot.xml'
if xml!=expected:raise RuntimeError('XML candidate journal target differs')
if xml.exists():
if xml.is_symlink() or digest(xml.read_bytes())!=old['patched_sha256']:raise RuntimeError('Changed loose XML preserved')
xml.rename(recovery/'inactive-Bindings_Camelot.xml')
report=dict(build=70334,target=str(TARGET.relative_to(ROOT)),files={k:digest(v) for k,v in files.items()},recovery=str(recovery.relative_to(ROOT)),original_client_modified=False,scope='Original friendly-nameplate boolean adapter, profession book third specialization button, circular profession output borders, and original character-sheet mounted-speed labels/source PvE defense estimates. No networking, learned-state changes or replacement windows.',rollback='Verify the owned manifest; restore previous-addon and previous-manifest.json from recovery, then reload UI. Do not restore inactive XML as a working fix.')
JOURNAL.write_text(json.dumps(report,indent=2)+'\n');TARGET.mkdir(parents=True,exist_ok=True)
for name,data in files.items():(TARGET/name).write_bytes(data)
(recovery/'manifest.json').write_text(json.dumps(report,indent=2)+'\n')
print('Installed original-UI control adapter in private client. Actual addon loading, keypresses and reload persistence still require verification.')
if __name__=='__main__':
p=argparse.ArgumentParser(description=__doc__);p.add_argument('action',choices=['install']);p.parse_args();install()