Chinese main menu: font atlas + GB2312 tables + Strings translation

- build_cjk.py: 2048x1024 UI atlas (original ASCII at 0,0 + full GB2312 at 12px) and
  cjk_glyph/cjk_metric tables.
- cn_strings.py + make_cn_strings.py: escape-aware GB2312 rewrite of Strings.dat (46 entries).
- install_cjk.py: one-shot deploy/restore (exe patch, atlas loose+res, strings).
- apply_cjk.py: fix metrics cave code byte order (was (second<<8)|first) so CJK width
  measures correctly and centred labels are no longer flushed right.
- docs: DEVLOG + patch notes for the atlas and the fix.
This commit is contained in:
DragonHD
2026-09-20 10:22:49 +08:00
parent caf7376019
commit 9eed020634
9 changed files with 671 additions and 15 deletions
+18 -12
View File
@@ -1,4 +1,4 @@
import struct, sys, os
import argparse, struct, sys, os
from keystone import Ks, KS_ARCH_X86, KS_MODE_32
ORIG = r"F:\steam\steamapps\common\The I of the Dragon\TheIOfTheDragon.exe"
@@ -21,16 +21,16 @@ def align(x, a):
return (x + a - 1) // a * a
def load_tables():
g = open(os.path.join(TBL, "cjk_glyph.bin"), "rb").read()
m = open(os.path.join(TBL, "cjk_metric.bin"), "rb").read()
def load_tables(tbl):
g = open(os.path.join(tbl, "cjk_glyph.bin"), "rb").read()
m = open(os.path.join(tbl, "cjk_metric.bin"), "rb").read()
assert len(g) == 65536 * 16, len(g)
assert len(m) == 65536 * 8, len(m)
return g, m
def main():
data = bytearray(open(ORIG, "rb").read())
def main(orig=ORIG, out=OUT, tbl=TBL):
data = bytearray(open(orig, "rb").read())
e_lfanew = struct.unpack_from("<I", data, 0x3C)[0]
coff = e_lfanew + 4
nsec = struct.unpack_from("<H", data, coff + 2)[0]
@@ -99,7 +99,8 @@ def main():
cmp al, 0x80
jb ascii
movzx eax, al
mov ah, byte ptr [ebx + 1]
shl eax, 8
mov al, byte ptr [ebx + 1]
mov ebp, [ecx + 0x14]
add ebp, dword ptr [eax*8 + {metric}]
add edx, ebp
@@ -147,7 +148,7 @@ def main():
data[sec_off + OFF_DRAW: sec_off + OFF_DRAW + len(draw_code)] = draw_code
data[sec_off + OFF_MEAS: sec_off + OFF_MEAS + len(meas_code)] = meas_code
glyph, metric = load_tables()
glyph, metric = load_tables(tbl)
data[sec_off + OFF_GLYPH: sec_off + OFF_GLYPH + len(glyph)] = glyph
data[sec_off + OFF_METRIC: sec_off + OFF_METRIC + len(metric)] = metric
@@ -164,10 +165,15 @@ def main():
hook(HOOK_DRAW_VA, draw_va)
hook(HOOK_MEAS_VA, meas_va)
os.makedirs(os.path.dirname(OUT), exist_ok=True)
open(OUT, "wb").write(data)
print("wrote", OUT, len(data), "bytes")
os.makedirs(os.path.dirname(out), exist_ok=True)
open(out, "wb").write(data)
print("wrote", out, len(data), "bytes")
if __name__ == "__main__":
main()
ap = argparse.ArgumentParser()
ap.add_argument("--orig", default=ORIG)
ap.add_argument("--out", default=OUT)
ap.add_argument("--tbl", default=TBL)
a = ap.parse_args()
main(a.orig, a.out, a.tbl)