#!/usr/bin/env python3 # 没有完整原版 RomFS(缺 build_manifest.psv)时,从现成 iOS 安装包解出的 DmIOS.app 取触屏素材:TouchArt PNG、hud_v4_ui、mapgoal、dm_touch_native_art.c。 # 每张 PNG 与技能索引都按仓库里冻结的 native_art_manifest.json 核过哈希(同 ios/tools/native_art/generate.py 的产物)。 # 用法:art_from_ipa.py <解开的 Payload/DmIOS.app> # Without a full original RomFS (no build_manifest.psv), take the touch art from an unpacked iOS build (DmIOS.app): TouchArt PNGs, hud_v4_ui, mapgoal, dm_touch_native_art.c. # Every PNG and the skill index are hash-checked against the frozen native_art_manifest.json (same output as ios/tools/native_art/generate.py). # Usage: art_from_ipa.py import hashlib, json, shutil, sys from pathlib import Path app = Path(sys.argv[1]); dm = Path(sys.argv[2]); ios = dm / 'ios'; nat = ios / 'tools/native_art' sha = lambda b: hashlib.sha256(b).hexdigest() mpath = ios / 'Sources/TouchArt/native_art_manifest.json'; man = json.loads(mpath.read_text()) art = ios / 'Sources/TouchArt'; atl = {} for a in man['assets']: b = (app / a['asset']).read_bytes() assert sha(b) == a['decoded_png_sha256'], a['asset'] (art / a['asset']).write_bytes(b); atl[a['asset']] = a rows = [[int(x) for x in l.split('\t')[1:4]] for l in open(app / 'dm/derived.tsv') if l.startswith('TAROW')] assert sha(json.dumps(rows, sort_keys=True, separators=(',', ':')).encode()) == man['descriptor_index_sha256'] out = ['/* Generated from frozen official Skills/Skilldesc; do not hand-edit rows. */', '#include "dm_touch_native_art.h"', '#include "../host/dm_input.h"', '#include ', 'const dm_ta_atlas dm_ta_atlases[DM_TA_ATLASES]={'] for i in range(9): a = atl['dm_native_skill_%d.png' % i]; out.append(' {"%s",%d,%d,%d,%d,%d},' % (a['asset'][:-4], *a['atlas_px'], a['frame_width'], a['frame_pitch'], a['frame_count'])) out += ['};', f'const char dm_ta_manifest_sha[]="{sha(mpath.read_bytes())}";', f'const char dm_ta_geometry_sha[]="{sha((ios / "docs/native_art_v1_geometry.json").read_bytes())}";', f'const char dm_ta_binding_sha[]="{sha((ios / "docs/touch_layout_spec_native_binding_v5.json").read_bytes())}";', 'static const struct { uint32_t id; int atlas,frame; } rows[]={'] out += [' {%d,%d,%d},' % tuple(r) for r in rows] + ['};', (nat / 'implementation.c.inc').read_text()] (dm / 'touch/dm_touch_native_art.c').write_text('\n'.join(out) + '\n') hud = ios / 'Gen/assets/NativeHUD/v4/hud_v4_ui' shutil.rmtree(hud, ignore_errors=True); shutil.copytree(app / 'hud_v4_ui', hud) goal = ios / 'Gen/assets/NativeHUD/mapgoal' # 小地图任务终点(gen_map_goal_art.py 的产物,按它的 mapgoal.json 核齐) | minimap quest goals (gen_map_goal_art.py output, checked complete against its mapgoal.json) shutil.rmtree(goal, ignore_errors=True); shutil.copytree(app / 'mapgoal', goal) gm = json.loads((goal / 'mapgoal.json').read_text()) need = ['cross.png'] + ['sym_%d.png' % i for i in range(gm['symbol_frames'])] assert all((goal / f).is_file() for f in need), 'mapgoal incomplete' print(len(rows), 'rows,', len(atl), 'atlases,', len(list(hud.iterdir())), 'hud files,', len(list(goal.iterdir())), 'mapgoal files')