39 lines
1.4 KiB
Python
39 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Adapt the original 70334 whisper editor to Octo's single character names."""
|
|
|
|
import argparse
|
|
import hashlib
|
|
from pathlib import Path
|
|
|
|
|
|
SOURCE_FDID = 7208180
|
|
SOURCE_PATH = "interface/addons/blizzard_chatframebase/shared/chatframeeditbox.lua"
|
|
SOURCE_SHA256 = "2fd4d36116d3f9365941f4b38416ec956c23aa327e54ad8aa5e5e114f9ae62b5"
|
|
ANCHOR = b'\tlocal targetMatchString = RegionalUniqueNamesEnabled() and "[%s-](%S+)%s" or "%s";'
|
|
REPLACEMENT = b'\tlocal targetMatchString = "%s"; -- Octo characters use one name.'
|
|
|
|
|
|
def transform(raw: bytes) -> bytes:
|
|
if not isinstance(raw, bytes) or hashlib.sha256(raw).hexdigest() != SOURCE_SHA256:
|
|
raise ValueError("Exact original 70334 ChatFrameEditBox.lua required")
|
|
if raw.count(ANCHOR) != 1:
|
|
raise ValueError("Original whisper target parser differs")
|
|
return raw.replace(ANCHOR, REPLACEMENT)
|
|
|
|
|
|
def main() -> None:
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument("original", type=Path)
|
|
parser.add_argument("output", type=Path)
|
|
args = parser.parse_args()
|
|
if args.original.resolve() == args.output.resolve():
|
|
parser.error("Keep the original UI file intact")
|
|
candidate = transform(args.original.read_bytes())
|
|
args.output.parent.mkdir(parents=True, exist_ok=True)
|
|
args.output.write_bytes(candidate)
|
|
print(f"FDID {SOURCE_FDID}: {hashlib.sha256(candidate).hexdigest()}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|