XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEEDToolBox

【WinUI】XFE精英危险工具箱

公开
关注 0 Fork 0 Star 0
UTF-8
"""Create the pinned texture index; decoded game images stay in the private QA cache."""
import hashlib,importlib.util,json,pathlib,re,struct,sys,zlib
sys.stdout.reconfigure(encoding='utf8')
spec=importlib.util.spec_from_file_location('a','research/galaxy_asset_inventory.py');saved=sys.argv;sys.argv=['x','unused']
a=importlib.util.module_from_spec(spec);spec.loader.exec_module(a);sys.argv=saved
rows=json.loads(pathlib.Path('artifacts/refit-0411-qa/local-ui-assets.json').read_text(encoding='utf8'));entries=[]
for row in rows:
    names=[s for s in row['strings'] if re.fullmatch(r'(item|module_category)_[a-z0-9_]+_icon',s)]
    if not names or 'FGDK:Texture:tex' not in row['strings']:continue
    path=pathlib.Path(row['path']);raw=a.decode(path)
    for m in re.finditer(rb'\x78[\x01\x9c\xda]',raw):
        try:data=zlib.decompress(raw[m.start():])
        except:continue
        break
    else:continue
    if len(data)<576:continue
    size=struct.unpack_from('<I',data,0xe8)[0];width,height=struct.unpack_from('<II',data,0x10c);pitch=struct.unpack_from('<I',data,0x12c)[0];fmt=data[0xd8]
    if fmt not in [98,99] or not 16<=width<=512 or not 16<=height<=512 or pitch%16 or size!=pitch*((height+3)//4) or len(data)-size<320:continue
    entries.append(dict(name=names[0],resourceHash=path.name,sourceSha256=hashlib.sha256(path.read_bytes()).hexdigest(),deflateOffset=m.start(),inflatedBytes=len(data),gpuOffset=len(data)-size,width=width,height=height,rowPitch=pitch,format=fmt))
target=pathlib.Path('XFEEDToolBox.Core/Rendering/local-module-icons.json');target.write_text(json.dumps(entries,indent=2),encoding='utf8')
print('Validated local game texture references:',len(entries));print(', '.join(e['name'] for e in entries if e['name'].startswith('module_category_')))