同步 hcr-gm-mod 源码

由 dsh-go 自动上传 · 2026/11/20 03:06:30
This commit is contained in:
dsh-go committed 2026-11-20 03:06:30 +08:00
1 parent 8ffaad1f5e
commit 00dd99028a
2 files changed
+255 -1

No files matched your search

+12 -1
View File
@@ -56,6 +56,11 @@ print(" manifest patched:", OLD, "->", NEW, "at", hex(p))
PY
ls -l out/AndroidManifest.xml
echo "== 2.7 哈基米皮肤:司机角色 + 默认车体换成猫 =="
rm -rf out/art
python3 patch_art.py base.apk out/art
ls -l out/art
echo "== 2.6 哈基米化:改 assets/translations/chinese*.po 的 UI 文案 =="
rm -rf out/po
python3 patch_po.py base.apk out/po
@@ -84,7 +89,13 @@ python3 - <<'PY'
import zipfile, shutil, time, os
replace = {"AndroidManifest.xml": "out/AndroidManifest.xml",
"assets/translations/chinese.po": "out/po/chinese.po",
"assets/translations/chinese-traditional.po": "out/po/chinese-traditional.po"}
"assets/translations/chinese-traditional.po": "out/po/chinese-traditional.po",
"assets/driver-head.png": "out/art/driver-head.png",
"assets/driver-body.png": "out/art/driver-body.png",
"assets/driver-beard-part1.png": "out/art/driver-beard-part1.png",
"assets/driver-beard-part2.png": "out/art/driver-beard-part2.png",
"assets/atlas/vehicles-0.png": "out/art/vehicles-0.png",
"assets/atlas/vehicles-1.png": "out/art/vehicles-1.png"}
new = {"classes6.dex": "out/dex/classes.dex",
"lib/arm64-v8a/libgm2.so": "out/libgm2.so"}
with zipfile.ZipFile("base.apk") as zin, zipfile.ZipFile("out/work.apk","w",zipfile.ZIP_DEFLATED, allowZip64=True) as zout:
+243
View File
@@ -0,0 +1,243 @@
#!/usr/bin/env python3
"""把游戏里的「司机角色 + 默认车体」画成哈基米猫。
- assets/driver-head.png -> 猫脸(同画布 128x128,保持透明留白)
- assets/driver-body.png -> 猫身体(沿用原轮廓做遮罩,换成奶白毛色 + 粉肚皮 + 斑纹)
- assets/driver-beard-part*.png-> 全透明(去掉胡子)
- assets/atlas/vehicles-1.png -> 'Car' / 'Car-skin-3' 帧:趴着的猫形车身
- assets/atlas/vehicles-0.png -> 'Car-skin-1' 帧:同上;'Tire' 轻微粉色轮毂
用法: python3 patch_art.py <src.apk> <out_dir>
"""
import io
import os
import sys
import zipfile
from PIL import Image, ImageDraw, ImageFilter
SS = 4 # 超采样倍数
FUR = (251, 247, 240)
FUR_DARK = (232, 224, 212)
LINE = (58, 50, 43)
PINK = (255, 182, 193)
PINK_DEEP= (255, 145, 164)
BLUSH = (255, 154, 162, 110)
EYE = (43, 43, 43)
def new(w, h):
return Image.new("RGBA", (w * SS, h * SS), (0, 0, 0, 0))
def down(im, w, h):
return im.resize((w, h), Image.LANCZOS)
def cat_head(w, h, spot=True):
"""猫脸:w×h 画布,脸占满中间偏下。"""
im = new(w, h)
d = ImageDraw.Draw(im)
W, H = w * SS, h * SS
def E(cx, cy, rx, ry, color, outline=None, width=0):
d.ellipse([cx - rx, cy - ry, cx + rx, cy + ry], fill=color,
outline=outline, width=width)
cx = W * 0.5
# ---- 耳朵 ----
earL = [(cx - W * 0.38, H * 0.34), (cx - W * 0.27, H * 0.02), (cx - W * 0.08, H * 0.24)]
earR = [(cx + W * 0.38, H * 0.34), (cx + W * 0.27, H * 0.02), (cx + W * 0.08, H * 0.24)]
d.polygon(earL, fill=FUR, outline=LINE, width=max(1, W // 120))
d.polygon(earR, fill=FUR, outline=LINE, width=max(1, W // 120))
d.polygon([(cx - W * 0.33, H * 0.30), (cx - W * 0.27, H * 0.09), (cx - W * 0.13, H * 0.25)], fill=PINK)
d.polygon([(cx + W * 0.33, H * 0.30), (cx + W * 0.27, H * 0.09), (cx + W * 0.13, H * 0.25)], fill=PINK)
# ---- 脸 ----
E(cx, H * 0.54, W * 0.46, H * 0.42, FUR, LINE, max(1, W // 150))
# 头顶一撮灰
if spot:
d.ellipse([cx - W * 0.12, H * 0.16, cx + W * 0.14, H * 0.30], fill=FUR_DARK)
# ---- 腮红 ----
blush = Image.new("RGBA", im.size, (0, 0, 0, 0))
bd = ImageDraw.Draw(blush)
bd.ellipse([cx - W * 0.40, H * 0.60, cx - W * 0.24, H * 0.70], fill=BLUSH)
bd.ellipse([cx + W * 0.24, H * 0.60, cx + W * 0.40, H * 0.70], fill=BLUSH)
blush = blush.filter(ImageFilter.GaussianBlur(W // 90))
im.alpha_composite(blush)
# ---- 眼睛 ----
E(cx - W * 0.17, H * 0.53, W * 0.062, H * 0.075, EYE)
E(cx + W * 0.17, H * 0.53, W * 0.062, H * 0.075, EYE)
E(cx - W * 0.155, H * 0.505, W * 0.020, H * 0.024, (255, 255, 255))
E(cx + W * 0.185, H * 0.505, W * 0.020, H * 0.024, (255, 255, 255))
# ---- 鼻子 ----
d.polygon([(cx - W * 0.035, H * 0.645), (cx + W * 0.035, H * 0.645), (cx, H * 0.685)], fill=PINK_DEEP)
# ---- 嘴(ω)----
lw = max(2, W // 90)
d.arc([cx - W * 0.10, H * 0.675, cx, H * 0.755], 0, 180, fill=LINE, width=lw)
d.arc([cx, H * 0.675, cx + W * 0.10, H * 0.755], 0, 180, fill=LINE, width=lw)
d.line([(cx, H * 0.685), (cx, H * 0.715)], fill=LINE, width=lw)
# ---- 胡须 ----
wl = max(1, W // 110)
for k, dy in enumerate((-0.02, 0.02, 0.06)):
d.line([(cx - W * 0.30, H * (0.66 + dy)), (cx - W * 0.47, H * (0.62 + dy * 1.6))], fill=LINE, width=wl)
d.line([(cx + W * 0.30, H * (0.66 + dy)), (cx + W * 0.47, H * (0.62 + dy * 1.6))], fill=LINE, width=wl)
return down(im, w, h)
def fur_tint(base, color, alpha=1.0):
"""把原图当成明暗模板,重染成指定毛色(保留原图的阴影与透明边缘)"""
src = base.convert("RGBA")
px = src.load()
w, h = src.size
out = Image.new("RGBA", (w, h), (0, 0, 0, 0))
op = out.load()
cr, cg, cb = color
for y in range(h):
for x in range(w):
r, g, b, a = px[x, y]
if a == 0:
continue
lum = (0.299 * r + 0.587 * g + 0.114 * b) / 255.0
shade = 0.62 + 0.55 * lum # 原图越亮 -> 越接近纯色
op[x, y] = (min(255, int(cr * shade)), min(255, int(cg * shade)),
min(255, int(cb * shade)), int(a * alpha))
return out
def cat_body(base):
"""司机身体:沿用原轮廓,重染奶白 + 粉肚皮 + 灰色斑纹"""
w, h = base.size
src = base.convert("RGBA")
out = fur_tint(src, FUR)
mask = src.split()[3]
# 肚皮(粉色,被轮廓裁切)
belly = Image.new("RGBA", (w * SS, h * SS), (0, 0, 0, 0))
bd = ImageDraw.Draw(belly)
bd.ellipse([w * SS * 0.30, h * SS * 0.52, w * SS * 0.72, h * SS * 0.96], fill=(255, 214, 222, 235))
belly = belly.resize((w, h), Image.LANCZOS)
# 斑纹(两块浅灰)
spot = Image.new("RGBA", (w * SS, h * SS), (0, 0, 0, 0))
sd = ImageDraw.Draw(spot)
sd.ellipse([w * SS * 0.06, h * SS * 0.10, w * SS * 0.34, h * SS * 0.30], fill=FUR_DARK)
sd.ellipse([w * SS * 0.62, h * SS * 0.06, w * SS * 0.90, h * SS * 0.24], fill=FUR_DARK)
spot = spot.resize((w, h), Image.LANCZOS)
out.alpha_composite(spot)
out.alpha_composite(belly)
# 用原 alpha 当蒙版(含羽化边)
keep = Image.new("RGBA", (w, h), (0, 0, 0, 0))
keep.paste(out, (0, 0), mask)
return keep
def cat_car(w, h):
"""趴着的猫形车身:车身=猫身,车头=猫脸(朝右),屁股=尾巴卷起来。"""
im = new(w, h)
d = ImageDraw.Draw(im)
W, H = w * SS, h * SS
lw = max(2, W // 130)
body = [W * 0.04, H * 0.34, W * 0.86, H * 1.02]
# 尾巴(左侧卷起)
d.arc([W * -0.02, H * 0.02, W * 0.20, H * 0.62], 300, 120, fill=FUR, width=int(W * 0.045))
d.arc([W * -0.02, H * 0.02, W * 0.20, H * 0.62], 300, 120, fill=LINE, width=max(1, lw // 2))
# 身体
d.ellipse(body, fill=FUR, outline=LINE, width=lw)
# 三条背部斑纹
for i, fx in enumerate((0.24, 0.42, 0.60)):
d.arc([W * (fx - 0.07), H * 0.30, W * (fx + 0.07), H * 0.62], 200, 340, fill=FUR_DARK, width=int(W * 0.022))
# 猫头(车头,右侧)
hx, hy, r = W * 0.80, H * 0.44, min(W * 0.20, H * 0.42)
ear1 = [(hx - r * 0.85, hy - r * 0.55), (hx - r * 0.55, hy - r * 1.55), (hx - r * 0.10, hy - r * 0.80)]
ear2 = [(hx + r * 0.85, hy - r * 0.55), (hx + r * 0.55, hy - r * 1.55), (hx + r * 0.10, hy - r * 0.80)]
d.polygon(ear1, fill=FUR, outline=LINE, width=lw)
d.polygon(ear2, fill=FUR, outline=LINE, width=lw)
d.polygon([(hx - r * 0.70, hy - r * 0.60), (hx - r * 0.52, hy - r * 1.30), (hx - r * 0.22, hy - r * 0.78)], fill=PINK)
d.polygon([(hx + r * 0.70, hy - r * 0.60), (hx + r * 0.52, hy - r * 1.30), (hx + r * 0.22, hy - r * 0.78)], fill=PINK)
d.ellipse([hx - r, hy - r, hx + r, hy + r], fill=FUR, outline=LINE, width=lw)
# 眼睛 / 鼻子 / 胡须
d.ellipse([hx - r * 0.52, hy - r * 0.22, hx - r * 0.22, hy + r * 0.16], fill=EYE)
d.ellipse([hx + r * 0.10, hy - r * 0.22, hx + r * 0.40, hy + r * 0.16], fill=EYE)
d.polygon([(hx - r * 0.10, hy + r * 0.28), (hx + r * 0.10, hy + r * 0.28), (hx, hy + r * 0.42)], fill=PINK_DEEP)
for dy in (-0.10, 0.06):
d.line([(hx + r * 0.30, hy + r * (0.30 + dy)), (hx + r * 0.95, hy + r * (0.20 + dy))], fill=LINE, width=max(1, lw // 2))
# 粉腮
d.ellipse([hx - r * 0.78, hy + r * 0.02, hx - r * 0.40, hy + r * 0.34], fill=(255, 154, 162, 150))
d.ellipse([hx + r * 0.40, hy + r * 0.02, hx + r * 0.78, hy + r * 0.34], fill=(255, 154, 162, 150))
return down(im, w, h)
def patch_atlas(atlas_img, rect, rotated, art):
atlas = atlas_img.copy()
x, y, w, h = rect
if rotated:
# 旋转帧:只做重染色,不改形状,避免坐标系出错
cell = atlas.crop((x, y, x + w, y + h))
tint = fur_tint(cell, FUR)
tint.putalpha(cell.split()[3])
atlas.paste(tint, (x, y))
return atlas
atlas.paste((0, 0, 0, 0), (x, y, x + w, y + h))
atlas.alpha_composite(art, (x, y))
return atlas
def main():
apk, outdir = sys.argv[1], sys.argv[2]
os.makedirs(outdir, exist_ok=True)
z = zipfile.ZipFile(apk)
# ---- 1. 司机头 ----
head = cat_head(128, 128)
head.save(os.path.join(outdir, "driver-head.png"))
print(" driver-head.png -> 猫脸", head.size)
# ---- 2. 司机身体 ----
body_src = Image.open(io.BytesIO(z.read("assets/driver-body.png")))
body = cat_body(body_src)
body.save(os.path.join(outdir, "driver-body.png"))
print(" driver-body.png -> 猫身体(沿用轮廓)", body.size)
# ---- 3. 去掉胡子 ----
for n in ("driver-beard-part1.png", "driver-beard-part2.png"):
src = Image.open(io.BytesIO(z.read("assets/" + n)))
Image.new("RGBA", src.size, (0, 0, 0, 0)).save(os.path.join(outdir, n))
print(" driver-beard-part1/2.png -> 透明(去胡子)")
# ---- 4. 车体帧:猫形车身 ----
import plistlib
for atlas_name, targets in (("vehicles-1", ["Car", "Car-skin-3"]),
("vehicles-0", ["Car-skin-1"])):
pl = plistlib.loads(z.read("assets/atlas/%s.plist" % atlas_name))
frames = pl["frames"]
png = z.read("assets/atlas/%s.png" % atlas_name)
img = Image.open(io.BytesIO(png)).convert("RGBA")
for name in targets:
f = frames[name]
w, h = [int(v) for v in f["spriteSize"].strip("{}").split(",")]
x, y = [int(v) for v in f["textureRect"].strip("{}").split("},{")[0].strip("{}").split(",")]
rot = bool(f.get("textureRotated"))
art = cat_car(w, h)
img = patch_atlas(img, (x, y, w, h), rot, art)
print(" %s :: %-12s %dx%d rot=%s -> 猫形车身" % (atlas_name, name, w, h, rot))
img.save(os.path.join(outdir, "%s.png" % atlas_name))
if __name__ == "__main__":
main()