Compare commits
No files matched your search
+17
@@ -21,3 +21,20 @@ src/history_*.lua
|
||||
# 密钥
|
||||
*.jks
|
||||
*.keystore
|
||||
|
||||
# dsh-go 自动补充
|
||||
node_modules/
|
||||
dist/
|
||||
build/
|
||||
.venv/
|
||||
venv/
|
||||
__pycache__/
|
||||
*.pyc
|
||||
.DS_Store
|
||||
*.log
|
||||
.env
|
||||
.env.*
|
||||
.dart_tool/
|
||||
.next/
|
||||
.cache/
|
||||
coverage/
|
||||
@@ -142,3 +142,12 @@ bash build.sh
|
||||
|
||||
- 仅用于单机存档的本地修改与逆向学习:本作有内购/广告,修改不产生真实收益,也不会解锁内购商品(金币是游戏内货币)。
|
||||
- 仓库不含原版 APK、`libgame.so`、签名密钥等二进制(见 `.gitignore`)。
|
||||
|
||||
## 本地大文件已被清理(腾空间)
|
||||
|
||||
`base.apk` / `libgame.so` / `out/` 已删除,源码、补丁脚本、build.sh、keystore 保留。
|
||||
重新构建前先恢复原包:
|
||||
|
||||
```
|
||||
cp "/sdcard/MT2/apks/Hill Climb Racing_1.66.0.apk" base.apk
|
||||
```
|
||||
@@ -4,10 +4,10 @@ set -e
|
||||
cd "$(dirname "$0")"
|
||||
mkdir -p out
|
||||
|
||||
echo "== 1. 编译 Java(Boot + Panel)-> classes6.dex =="
|
||||
echo "== 1. 编译 Java(Boot + Panel + Hachimi)-> classes6.dex =="
|
||||
rm -rf out/classes out/dex && mkdir -p out/classes out/dex
|
||||
javac -source 8 -target 8 -nowarn -classpath /usr/lib/android-sdk/platforms/android-23/android.jar \
|
||||
-d out/classes src/com/gm/Boot.java src/com/gm/Panel.java src/com/gm/Native.java 2>&1 \
|
||||
-d out/classes src/com/gm/Boot.java src/com/gm/Panel.java src/com/gm/Native.java src/com/gm/Hachimi.java 2>&1 \
|
||||
| grep -v "bootstrap class path\|source value 8\|target value 8\|deprecat\|警告\|warning" || true
|
||||
java -cp /tmp/r8.jar com.android.tools.r8.D8 --min-api 21 --lib /usr/lib/android-sdk/platforms/android-23/android.jar \
|
||||
--output out/dex $(find out/classes -name '*.class') 2>&1 | tail -3
|
||||
@@ -56,6 +56,25 @@ print(" manifest patched:", OLD, "->", NEW, "at", hex(p))
|
||||
PY
|
||||
ls -l out/AndroidManifest.xml
|
||||
|
||||
echo "== 2.8 哈基米 BGM:合成三首曲子替换游戏音乐 =="
|
||||
rm -rf out/audio
|
||||
python3 make_music.py out/audio
|
||||
ls -l out/audio
|
||||
|
||||
echo "== 2.9 哈基米启动动画:替换 assets/splash/splash.gif 与 game-logo =="
|
||||
rm -rf out/splash
|
||||
python3 patch_splash.py base.apk out/splash
|
||||
|
||||
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
|
||||
ls -l out/po
|
||||
|
||||
echo "== 2.5 AdMob 广告位全部失效(同长度替换为 0)=="
|
||||
python3 - <<'PYPATCH'
|
||||
import zipfile, re, hashlib, zlib, struct
|
||||
@@ -77,7 +96,29 @@ ls -l out/classes2.dex
|
||||
echo "== 3. 重新打包 =="
|
||||
python3 - <<'PY'
|
||||
import zipfile, shutil, time, os
|
||||
replace = {"AndroidManifest.xml": "out/AndroidManifest.xml"}
|
||||
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/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",
|
||||
"assets/audio/bgmusic00.ogg": "out/audio/hachimi_ingame.ogg",
|
||||
"assets/audio/bgmusic01.ogg": "out/audio/hachimi_ingame.ogg",
|
||||
"assets/audio/bgmusic-pop.ogg": "out/audio/hachimi_ingame.ogg",
|
||||
"assets/audio/bgmusic-metal.ogg": "out/audio/hachimi_ingame.ogg",
|
||||
"assets/audio/bgmusic-neon.ogg": "out/audio/hachimi_ingame.ogg",
|
||||
"assets/audio/bgmusic-prog.ogg": "out/audio/hachimi_ingame.ogg",
|
||||
"assets/audio/bgmusic-halloween.ogg": "out/audio/hachimi_ingame.ogg",
|
||||
"assets/audio/8bit-ingame.ogg": "out/audio/hachimi_ingame.ogg",
|
||||
"assets/audio/8bit-menu.ogg": "out/audio/hachimi_menu.ogg",
|
||||
"assets/audio/8bit-garage.ogg": "out/audio/hachimi_menu.ogg",
|
||||
"assets/audio/8bit-hiscore.ogg": "out/audio/hachimi_jingle.ogg",
|
||||
"assets/splash/splash.gif": "out/splash/splash.gif",
|
||||
"assets/game-logo.png": "out/splash/game-logo.png",
|
||||
"assets/game-logo-HD.png": "out/splash/game-logo-HD.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:
|
||||
|
||||
+234
@@ -0,0 +1,234 @@
|
||||
#!/usr/bin/env python3
|
||||
"""生成「哈基米」主题 BGM(纯合成,不用外部素材),输出 OGG/Vorbis。
|
||||
|
||||
用法: python3 make_music.py <out_dir>
|
||||
产出:
|
||||
hachimi_menu.ogg 菜单/车库用(慢速音乐盒 + 猫叫)
|
||||
hachimi_ingame.ogg 比赛用(148 BPM 芯片风,主旋律是三音「哈-基-米」动机)
|
||||
hachimi_jingle.ogg 结算/高分用(短 jingle)
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
|
||||
import numpy as np
|
||||
import soundfile as sf
|
||||
|
||||
SR = 44100
|
||||
|
||||
|
||||
def f(midi_note):
|
||||
return 440.0 * 2 ** ((midi_note - 69) / 12.0)
|
||||
|
||||
|
||||
def env(n, a=0.01, d=0.08, s=0.7, r=0.12):
|
||||
"""简单 ADS R包络,n = 采样点数"""
|
||||
a_n, d_n, r_n = int(SR * a), int(SR * d), int(SR * r)
|
||||
s_n = max(0, n - a_n - d_n - r_n)
|
||||
e = np.concatenate([
|
||||
np.linspace(0, 1, a_n, endpoint=False),
|
||||
np.linspace(1, s, d_n, endpoint=False),
|
||||
np.full(s_n, s),
|
||||
np.linspace(s, 0, r_n),
|
||||
])
|
||||
if len(e) < n:
|
||||
e = np.pad(e, (0, n - len(e)))
|
||||
return e[:n]
|
||||
|
||||
|
||||
def square(freq, dur, duty=0.25, detune=0.0, vib=0.0):
|
||||
n = int(SR * dur)
|
||||
t = np.arange(n) / SR
|
||||
fr = freq * (1 + vib * np.sin(2 * np.pi * 5.5 * t)) * (1 + detune)
|
||||
ph = (t * fr) % 1.0
|
||||
return np.where(ph < duty, 1.0, -1.0)
|
||||
|
||||
|
||||
def triangle(freq, dur):
|
||||
n = int(SR * dur)
|
||||
t = np.arange(n) / SR
|
||||
ph = (t * freq) % 1.0
|
||||
return 4 * np.abs(ph - 0.5) - 1
|
||||
|
||||
|
||||
def sine(freq, dur):
|
||||
n = int(SR * dur)
|
||||
t = np.arange(n) / SR
|
||||
return np.sin(2 * np.pi * freq * t)
|
||||
|
||||
|
||||
def noise(dur, seed=0):
|
||||
rng = np.random.default_rng(seed)
|
||||
return rng.standard_normal(int(SR * dur))
|
||||
|
||||
|
||||
def meow(dur=0.42, pitch=1.0, seed=7):
|
||||
"""合成一声「喵」:音高先升后降 + 两个共振峰 + 轻微噪声"""
|
||||
n = int(SR * dur)
|
||||
t = np.arange(n) / SR
|
||||
# 音高曲线:300 -> 780 -> 420 Hz
|
||||
base = np.interp(t, [0, dur * 0.28, dur * 0.62, dur], [300, 790, 640, 420]) * pitch
|
||||
ph = np.cumsum(base) / SR
|
||||
src = np.where((ph % 1.0) < 0.35, 1.0, -0.55) # 近似声门波
|
||||
# 两个共振峰(元音 /miao/)
|
||||
out = np.zeros(n)
|
||||
for fr, amp in ((720, 1.0), (1180, 0.55), (2600, 0.22)):
|
||||
out += amp * np.sin(2 * np.pi * fr * t) * np.interp(t, [0, dur], [1, 0.6])
|
||||
out = out * 0.55 + src * 0.45
|
||||
out += 0.05 * noise(dur, seed) * np.exp(-t * 6)
|
||||
return out * env(n, a=0.02, d=0.1, s=0.55, r=0.18)
|
||||
|
||||
|
||||
class Track:
|
||||
def __init__(self, bpm, seconds):
|
||||
self.bpm = bpm
|
||||
self.spb = 60.0 / bpm # 秒 / 拍
|
||||
self.buf = np.zeros(int(SR * seconds) + SR)
|
||||
self.seconds = seconds
|
||||
|
||||
def add(self, sig, at_beat, gain=0.3):
|
||||
i = int(at_beat * self.spb * SR)
|
||||
j = min(len(self.buf), i + len(sig))
|
||||
if i >= len(self.buf):
|
||||
return
|
||||
self.buf[i:j] += sig[: j - i] * gain
|
||||
|
||||
def note(self, midi, at, dur, gain=0.3, kind="square", duty=0.25, vib=0.0):
|
||||
fr = f(midi)
|
||||
if kind == "square":
|
||||
s = square(fr, dur, duty, 0.0, vib)
|
||||
elif kind == "triangle":
|
||||
s = triangle(fr, dur)
|
||||
elif kind == "sine":
|
||||
s = sine(fr, dur)
|
||||
else:
|
||||
s = square(fr, dur, 0.5)
|
||||
self.add(s * env(len(s)), at, gain)
|
||||
|
||||
def kick(self, at, gain=0.5):
|
||||
dur = 0.16
|
||||
n = int(SR * dur)
|
||||
t = np.arange(n) / SR
|
||||
s = np.sin(2 * np.pi * np.interp(t, [0, dur], [120, 45]) * t) * np.exp(-t * 22)
|
||||
self.add(s, at, gain)
|
||||
|
||||
def hat(self, at, gain=0.14, seed=1):
|
||||
n = int(SR * 0.05)
|
||||
s = noise(0.05, seed)[:n] * np.exp(-np.arange(n) / SR * 70)
|
||||
self.add(s, at, gain)
|
||||
|
||||
def meow_at(self, at, gain=0.5, pitch=1.0):
|
||||
self.add(meow(pitch=pitch), at, gain)
|
||||
|
||||
def render(self, fade=0.0):
|
||||
"""fade=0 用于循环播放的曲子(首尾不淡入淡出,接缝才不咔哒);jingle 才给 fade"""
|
||||
b = self.buf[: int(SR * self.seconds)].copy()
|
||||
if fade > 0:
|
||||
nf = int(SR * fade)
|
||||
b[:nf] *= np.linspace(0, 1, nf)
|
||||
b[-nf:] *= np.linspace(1, 0, nf)
|
||||
peak = np.max(np.abs(b)) or 1.0
|
||||
return (b / peak * 0.88).astype(np.float32)
|
||||
|
||||
|
||||
def ingame(seconds=64.0):
|
||||
"""比赛 BGM:148 BPM,动机「哈-基-米」= 三个上行音 G-A-C"""
|
||||
t = Track(148, seconds)
|
||||
bpb = 4
|
||||
bars = int(seconds / (t.spb * bpb))
|
||||
prog = [[60, 64, 67], [57, 60, 64], [53, 57, 60], [55, 59, 62]] # C Am F G
|
||||
motif = [(67, 0.5), (69, 0.5), (72, 0.5), (72, 0.5), (69, 0.5), (67, 0.5), (64, 1.0)]
|
||||
for bar in range(bars):
|
||||
ch = prog[bar % 4]
|
||||
base = bar * bpb
|
||||
# 贝斯:根音八分
|
||||
for k in range(8):
|
||||
t.note(ch[0] - 24 + (12 if k % 4 == 3 else 0), base + k * 0.5, 0.42, 0.30, "triangle")
|
||||
# 和弦垫(方波,弱)
|
||||
for k in range(4):
|
||||
for nn in ch:
|
||||
t.note(nn, base + k, 0.9, 0.075, "square", duty=0.5)
|
||||
# 主旋律:第 1、3 小节走动机,2、4 小节变奏
|
||||
if bar % 4 in (0, 2):
|
||||
pos = base
|
||||
for nn, dd in motif:
|
||||
t.note(nn + 12, pos, dd * 0.92, 0.30, "square", duty=0.25, vib=0.004)
|
||||
pos += dd
|
||||
if pos < base + bpb:
|
||||
t.note(64 + 12, pos, 0.6, 0.26, "square", duty=0.25)
|
||||
else:
|
||||
pos = base
|
||||
for nn, dd in [(72, 0.5), (74, 0.5), (76, 0.5), (79, 0.75), (76, 0.5), (72, 1.0)]:
|
||||
t.note(nn, pos, dd * 0.9, 0.28, "square", duty=0.25, vib=0.004)
|
||||
pos += dd
|
||||
# 鼓
|
||||
for k in range(4):
|
||||
t.kick(base + k, 0.5 if k in (0, 2) else 0.32)
|
||||
for k in range(8):
|
||||
t.hat(base + k * 0.5, 0.13 if k % 2 else 0.09, seed=bar * 8 + k)
|
||||
# 每 4 小节一声喵
|
||||
if bar % 4 == 3:
|
||||
t.meow_at(base + 2.5, 0.42, pitch=1.0 + 0.05 * (bar % 3))
|
||||
return t.render()
|
||||
|
||||
|
||||
def menu(seconds=48.0):
|
||||
"""菜单/车库:96 BPM 音乐盒 + 轻垫底"""
|
||||
t = Track(96, seconds)
|
||||
bars = int(seconds / (t.spb * 4))
|
||||
prog = [[60, 64, 67, 72], [57, 60, 64, 69], [53, 57, 60, 65], [55, 59, 62, 67]]
|
||||
arp = [0, 1, 2, 3, 2, 1, 2, 3]
|
||||
for bar in range(bars):
|
||||
ch = prog[bar % 4]
|
||||
base = bar * 4
|
||||
for k, idx in enumerate(arp):
|
||||
t.note(ch[idx] + 12, base + k * 0.5, 0.55, 0.22, "sine")
|
||||
for k in range(4):
|
||||
t.note(ch[0] - 24, base + k, 0.9, 0.16, "triangle")
|
||||
if bar % 4 == 2:
|
||||
t.meow_at(base + 1.5, 0.36, pitch=0.95)
|
||||
if bar % 4 == 0:
|
||||
t.kick(base, 0.22)
|
||||
return t.render()
|
||||
|
||||
|
||||
def jingle(seconds=9.0):
|
||||
t = Track(132, seconds)
|
||||
seq = [(72, 0.4), (76, 0.4), (79, 0.4), (84, 0.9),
|
||||
(79, 0.4), (76, 0.4), (72, 0.8)]
|
||||
pos = 0.0
|
||||
for nn, dd in seq:
|
||||
t.note(nn, pos, dd, 0.34, "square", duty=0.3, vib=0.005)
|
||||
t.note(nn - 12, pos, dd, 0.16, "triangle")
|
||||
pos += dd
|
||||
for k in range(6):
|
||||
t.kick(k, 0.35)
|
||||
t.meow_at(4.6, 0.55, pitch=1.1)
|
||||
t.meow_at(5.6, 0.5, pitch=0.9)
|
||||
return t.render()
|
||||
|
||||
|
||||
def main():
|
||||
out = sys.argv[1] if len(sys.argv) > 1 else "out/audio"
|
||||
os.makedirs(out, exist_ok=True)
|
||||
jobs = [("hachimi_ingame.ogg", ingame(), 0.02),
|
||||
("hachimi_menu.ogg", menu(), 0.02),
|
||||
("hachimi_jingle.ogg", jingle(), 0.0)]
|
||||
for name, data, fade in jobs:
|
||||
p = os.path.join(out, name)
|
||||
if fade:
|
||||
nf = int(SR * fade)
|
||||
data = data.copy()
|
||||
data[:nf] *= np.linspace(0, 1, nf)
|
||||
data[-nf:] *= np.linspace(1, 0, nf)
|
||||
# 分块写:这个 proot 里 libsndfile 一次写 2M+ 采样会段错误
|
||||
st = np.stack([data, data], axis=1) # 原曲大多是立体声,这里双声道输出
|
||||
with sf.SoundFile(p, "w", SR, 2, format="OGG", subtype="VORBIS") as fo:
|
||||
for i in range(0, len(st), 22050):
|
||||
fo.write(st[i:i + 22050])
|
||||
info = sf.info(p)
|
||||
print(" %-20s %5.1fs %d Hz %.0f KB" % (name, info.duration, info.samplerate,
|
||||
os.path.getsize(p) / 1024))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
+243
@@ -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()
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
#!/usr/bin/env python3
|
||||
"""把游戏中文 .po 里的常见 UI 词条换成「哈基米」风味。
|
||||
|
||||
用法:python3 patch_po.py <src.apk> <out_dir>
|
||||
产出:<out_dir>/chinese.po、<out_dir>/chinese-traditional.po
|
||||
原理:.po 是纯文本,逐「块」(以空行分隔)解析,命中 msgid 的块整体替换 msgstr,
|
||||
其余块逐字节保留,不重排、不改注释。
|
||||
"""
|
||||
import sys, re, zipfile, os
|
||||
|
||||
# msgid -> 哈基米化后的文案
|
||||
MAP = {
|
||||
"COINS": "哈基米币",
|
||||
"GEMS": "哈基米石",
|
||||
"GET COINS": "领哈基米币",
|
||||
"GET GEMS": "领哈基米石",
|
||||
"DOUBLE COINS": "双倍哈基米币",
|
||||
"DOUBLE": "哈基米双倍",
|
||||
"SHOP": "哈基米商店",
|
||||
"Parts Shop": "哈基米零件店",
|
||||
"PARTS SHOP": "哈基米零件店",
|
||||
"GARAGE": "哈基米车库",
|
||||
"GARAGE LOCKED": "哈基米车库锁了",
|
||||
"PLAY": "哈基米出发",
|
||||
"START": "哈基米冲",
|
||||
"START ": "哈基米冲",
|
||||
"READY": "哈基米就绪",
|
||||
"DRIVE": "哈基米驾驶",
|
||||
"RESTART": "再来一喵",
|
||||
"NEXT": "下一只哈基米",
|
||||
"SELECT": "挑一下喵",
|
||||
"SELECT STAGE": "选个哈基米关卡",
|
||||
"SELECT VEHICLE": "选个哈基米座驾",
|
||||
"STAGE": "哈基米关卡",
|
||||
"LEVEL ": "哈基米等级",
|
||||
"MAX LEVEL": "哈基米满级",
|
||||
"MAXIMUM LEVEL": "哈基米满级",
|
||||
"UPGRADE": "哈基米强化",
|
||||
"UPGRADE CAR": "强化哈基米车",
|
||||
"UNLOCK": "哈基米解封",
|
||||
"UNLOCK ALL": "全哈基米解封",
|
||||
"SETTINGS": "哈基米设置",
|
||||
"BACK": "回去喵",
|
||||
"CLOSE": "关喵",
|
||||
"Close": "关喵",
|
||||
"SAVE": "存喵",
|
||||
"BUY": "哈基米买",
|
||||
"FREE": "哈基米白送",
|
||||
"MY CAR": "我的哈基米车",
|
||||
"NEW CAR": "新的哈基米车",
|
||||
"WATCH AD": "看哈基米广告",
|
||||
"NO ADS": "没有广告喵",
|
||||
"AD FREE": "哈基米无广告",
|
||||
"DRIVER DOWN ": "哈基米倒了",
|
||||
"Battle is over!": "哈基米战斗结束!",
|
||||
"BONUS REWARD!": "哈基米奖励!",
|
||||
"GET REWARD!": "领哈基米奖励!",
|
||||
"OK": "喵",
|
||||
}
|
||||
|
||||
UNQ = re.compile(r'"((?:[^"\\]|\\.)*)"')
|
||||
|
||||
|
||||
def unquote(s):
|
||||
out = "".join(UNQ.findall(s))
|
||||
return out.replace("\\n", "\n").replace('\\"', '"').replace("\\\\", "\\")
|
||||
|
||||
|
||||
def quote(s):
|
||||
return '"' + s.replace("\\", "\\\\").replace('"', '\\"').replace("\n", "\\n") + '"'
|
||||
|
||||
|
||||
def patch(text):
|
||||
lines = text.split("\n")
|
||||
# 切块:空行分隔
|
||||
blocks, cur = [], []
|
||||
for ln in lines:
|
||||
if ln.strip() == "":
|
||||
blocks.append(cur)
|
||||
cur = []
|
||||
else:
|
||||
cur.append(ln)
|
||||
blocks.append(cur)
|
||||
|
||||
hits = 0
|
||||
out = []
|
||||
for b in blocks:
|
||||
mid = next((i for i, l in enumerate(b) if l.startswith("msgid ")), None)
|
||||
mst = next((i for i, l in enumerate(b) if l.startswith("msgstr ")), None)
|
||||
if mid is not None and mst is not None:
|
||||
key = unquote(b[mid][len("msgid "):])
|
||||
if key in MAP:
|
||||
# msgstr 可能是多行引号块,整段替换成单行
|
||||
end = mst + 1
|
||||
while end < len(b) and b[end].startswith('"'):
|
||||
end += 1
|
||||
b = b[:mst] + ["msgstr " + quote(MAP[key])] + b[end:]
|
||||
hits += 1
|
||||
out.append(b)
|
||||
res = "\n".join(l for blk in out for l in (blk + [""]))
|
||||
return res, hits
|
||||
|
||||
|
||||
def main():
|
||||
apk, outdir = sys.argv[1], sys.argv[2]
|
||||
os.makedirs(outdir, exist_ok=True)
|
||||
z = zipfile.ZipFile(apk)
|
||||
for name in ("chinese.po", "chinese-traditional.po"):
|
||||
arc = "assets/translations/" + name
|
||||
try:
|
||||
src = z.read(arc).decode("utf-8")
|
||||
except KeyError:
|
||||
print(" skip", arc, "(不在包里)")
|
||||
continue
|
||||
new, hits = patch(src)
|
||||
path = os.path.join(outdir, name)
|
||||
open(path, "w", encoding="utf-8", newline="\n").write(new)
|
||||
print(" %-28s 命中 %d 条 -> %s (%d -> %d 字节)" % (name, hits, path, len(src), len(new)))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
+333
@@ -0,0 +1,333 @@
|
||||
#!/usr/bin/env python3
|
||||
"""把《登山赛车》的启动动画换成哈基米版。
|
||||
|
||||
原资源:assets/splash/splash.gif(713x713、62 帧、40ms/帧、黑底白 logo)
|
||||
新资源:同样 713x713 / 62 帧 / 40ms,黑底,小白猫 + 「哈基米」字样动画。
|
||||
顺带把 assets/game-logo.png(256) 与 game-logo-HD.png(512) 换成哈基米猫脸 logo。
|
||||
|
||||
用法: python3 patch_splash.py <base.apk> <out_dir>
|
||||
输出: out_dir/splash/splash.gif, out_dir/splash/game-logo.png, out_dir/splash/game-logo-HD.png
|
||||
"""
|
||||
import math
|
||||
import os
|
||||
import sys
|
||||
import zipfile
|
||||
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
W = 713 # 画布边长(与原 splash.gif 一致)
|
||||
FRAMES = 62
|
||||
FRAME_MS = 40
|
||||
SS = 2 # 超采样倍数
|
||||
CJK = "/system/fonts/NotoSansCJK-Bold.ttc"
|
||||
CJK_IDX = 2 # ttc 里第 2 个是 Simplified Chinese
|
||||
|
||||
INK = (38, 32, 26, 255) # 深色线条
|
||||
FUR = (251, 244, 232, 255) # 奶白
|
||||
FUR_SH = (232, 220, 203, 255)
|
||||
PINK = (255, 176, 190, 255)
|
||||
BLUSH = (255, 150, 170, 90)
|
||||
TXT = (255, 255, 255, 255)
|
||||
TXT_GLOW = (255, 200, 216, 70)
|
||||
|
||||
|
||||
def ease_out_back(t, s=1.9):
|
||||
t = min(max(t, 0.0), 1.0)
|
||||
return 1 + (s + 1) * (t - 1) ** 3 + s * (t - 1) ** 2
|
||||
|
||||
|
||||
def ease_out(t):
|
||||
t = min(max(t, 0.0), 1.0)
|
||||
return 1 - (1 - t) ** 3
|
||||
|
||||
|
||||
def clamp01(t):
|
||||
return min(max(t, 0.0), 1.0)
|
||||
|
||||
|
||||
def tri(d, p, fill):
|
||||
d.polygon(p, fill=fill)
|
||||
|
||||
|
||||
def cat_head(px, eye="open", mouth="w", blush=True, spot=True, ear_h=1.0):
|
||||
"""画一只正面猫头,返回 RGBA 图(边长 px,猫头居中)。"""
|
||||
im = Image.new("RGBA", (px, px), (0, 0, 0, 0))
|
||||
d = ImageDraw.Draw(im)
|
||||
c = px / 2.0
|
||||
R = px * 0.33
|
||||
|
||||
# 耳朵(先画,压在头下面)
|
||||
eh = R * 0.78 * ear_h
|
||||
for sx in (-1, 1):
|
||||
bx = c + sx * R * 0.62
|
||||
tri(d, [(bx - R * 0.30, c - R * 0.42),
|
||||
(bx + R * 0.30, c - R * 0.52),
|
||||
(bx + sx * R * 0.18, c - R * 0.42 - eh)], FUR)
|
||||
tri(d, [(bx - R * 0.14, c - R * 0.48),
|
||||
(bx + R * 0.14, c - R * 0.53),
|
||||
(bx + sx * R * 0.09, c - R * 0.42 - eh * 0.55)], PINK)
|
||||
|
||||
# 脸
|
||||
d.ellipse([c - R, c - R * 0.92, c + R, c + R * 0.98], fill=FUR)
|
||||
# 下巴阴影
|
||||
d.arc([c - R * 0.75, c + R * 0.25, c + R * 0.75, c + R * 0.95], 20, 160, fill=FUR_SH, width=max(2, int(px * 0.006)))
|
||||
|
||||
if spot:
|
||||
d.ellipse([c + R * 0.10, c - R * 0.88, c + R * 0.62, c - R * 0.52], fill=(228, 216, 200, 255))
|
||||
|
||||
# 眼睛
|
||||
ex, ey = R * 0.40, R * 0.06
|
||||
ew, eh2 = R * 0.155, R * 0.215
|
||||
for sx in (-1, 1):
|
||||
cx = c + sx * ex
|
||||
if eye == "open":
|
||||
d.ellipse([cx - ew, c + ey - eh2, cx + ew, c + ey + eh2], fill=INK)
|
||||
d.ellipse([cx - ew * 0.34, c + ey - eh2 * 0.55, cx + ew * 0.34, c + ey + eh2 * 0.1], fill=(255, 255, 255, 235))
|
||||
elif eye == "closed":
|
||||
d.arc([cx - ew * 1.25, c + ey - eh2 * 0.85, cx + ew * 1.25, c + ey + eh2 * 0.85], 200, 340,
|
||||
fill=INK, width=max(2, int(px * 0.010)))
|
||||
elif eye == "happy":
|
||||
d.arc([cx - ew * 1.2, c + ey - eh2 * 0.2, cx + ew * 1.2, c + ey + eh2 * 1.4], 200, 340,
|
||||
fill=INK, width=max(2, int(px * 0.011)))
|
||||
# 高光
|
||||
if eye == "open":
|
||||
d.ellipse([cx + ew * 0.05, c + ey - eh2 * 0.62, cx + ew * 0.42, c + ey - eh2 * 0.18], fill=(255, 255, 255, 240))
|
||||
|
||||
# 鼻子
|
||||
nw = R * 0.10
|
||||
ny = c + R * 0.30
|
||||
d.polygon([(c - nw, ny - nw * 0.5), (c + nw, ny - nw * 0.5), (c, ny + nw * 0.7)], fill=(240, 140, 158, 255))
|
||||
|
||||
# 嘴
|
||||
mw = R * 0.16
|
||||
if mouth == "w":
|
||||
d.arc([c - mw * 1.9, ny - mw * 0.1, c, ny + mw * 1.5], 20, 150, fill=INK, width=max(2, int(px * 0.008)))
|
||||
d.arc([c, ny - mw * 0.1, c + mw * 1.9, ny + mw * 1.5], 30, 160, fill=INK, width=max(2, int(px * 0.008)))
|
||||
elif mouth == "open":
|
||||
d.ellipse([c - mw, ny + mw * 0.1, c + mw, ny + mw * 1.9], fill=(120, 60, 66, 255))
|
||||
|
||||
# 胡须
|
||||
lw = max(2, int(px * 0.006))
|
||||
for sx in (-1, 1):
|
||||
for k, dy in enumerate((-0.10, 0.02, 0.14)):
|
||||
x0 = c + sx * R * 0.52
|
||||
x1 = c + sx * R * (1.16 + 0.05 * k)
|
||||
y0 = c + R * (0.22 + dy)
|
||||
y1 = c + R * (0.16 + dy * 1.5)
|
||||
d.line([(x0, y0), (x1, y1)], fill=(214, 203, 188, 230), width=lw)
|
||||
|
||||
if blush:
|
||||
for sx in (-1, 1):
|
||||
cx = c + sx * R * 0.62
|
||||
d.ellipse([cx - R * 0.17, c + R * 0.16, cx + R * 0.17, c + R * 0.34], fill=BLUSH)
|
||||
return im
|
||||
|
||||
|
||||
def heart(size, color):
|
||||
im = Image.new("RGBA", (size, size), (0, 0, 0, 0))
|
||||
d = ImageDraw.Draw(im)
|
||||
s = size
|
||||
d.ellipse([0, 0, s * 0.55, s * 0.55], fill=color)
|
||||
d.ellipse([s * 0.45, 0, s, s * 0.55], fill=color)
|
||||
d.polygon([(s * 0.02, s * 0.42), (s * 0.98, s * 0.42), (s * 0.5, s)], fill=color)
|
||||
return im
|
||||
|
||||
|
||||
def paw(size, color):
|
||||
im = Image.new("RGBA", (size, size), (0, 0, 0, 0))
|
||||
d = ImageDraw.Draw(im)
|
||||
s = size
|
||||
d.ellipse([s * 0.18, s * 0.36, s * 0.82, s * 0.95], fill=color)
|
||||
for k, (dx, dy) in enumerate([(0.08, 0.10), (0.30, 0.02), (0.55, 0.02), (0.76, 0.11)]):
|
||||
d.ellipse([s * dx, s * dy, s * dx + s * 0.19, s * dy + s * 0.21], fill=color)
|
||||
return im
|
||||
|
||||
|
||||
def tail(d, cx, cy, R, phase, alpha=255):
|
||||
"""在右侧画一条摇动的猫尾"""
|
||||
pts = []
|
||||
for i in range(26):
|
||||
t = i / 25.0
|
||||
ang = -0.6 + 1.9 * t + 0.5 * math.sin(phase + t * 2.2)
|
||||
rr = R * (1.02 + 0.55 * t)
|
||||
pts.append((cx + math.cos(ang) * rr, cy + math.sin(ang) * rr * 0.9 + R * 0.55 * t))
|
||||
col = (FUR[0], FUR[1], FUR[2], alpha)
|
||||
d.line(pts, fill=col, width=int(R * 0.34), joint="curve")
|
||||
d.line(pts, fill=(255, 214, 224, alpha), width=int(R * 0.14), joint="curve")
|
||||
|
||||
|
||||
def text_layer(txt, px_h, color=TXT, spacing_ratio=0.06):
|
||||
"""把一段中文渲染成紧凑的图层(带字距)"""
|
||||
font = ImageFont.truetype(CJK, px_h, index=CJK_IDX)
|
||||
glyphs = []
|
||||
total = 0
|
||||
for ch in txt:
|
||||
im = Image.new("RGBA", (px_h * 2, px_h * 2), (0, 0, 0, 0))
|
||||
d = ImageDraw.Draw(im)
|
||||
d.text((px_h * 0.2, px_h * 0.2), ch, font=font, fill=color)
|
||||
bb = im.getbbox()
|
||||
g = im.crop(bb)
|
||||
glyphs.append(g)
|
||||
total += g.width
|
||||
gap = int(px_h * spacing_ratio)
|
||||
h = max(g.height for g in glyphs)
|
||||
total = sum(g.width for g in glyphs) + gap * (len(glyphs) - 1)
|
||||
out = Image.new("RGBA", (total, h), (0, 0, 0, 0))
|
||||
x = 0
|
||||
for g in glyphs:
|
||||
out.alpha_composite(g, (x, h - g.height))
|
||||
x += g.width + gap
|
||||
return glyphs, gap, h
|
||||
|
||||
|
||||
_TEXT_CACHE = {}
|
||||
|
||||
|
||||
def text_parts(px_h):
|
||||
key = int(px_h)
|
||||
if key not in _TEXT_CACHE:
|
||||
_TEXT_CACHE[key] = text_layer("哈基米", key)
|
||||
return _TEXT_CACHE[key]
|
||||
|
||||
|
||||
def frame(i):
|
||||
"""生成第 i 帧(未超采样的 canvas 上画,随后 downscale)"""
|
||||
S = W * SS
|
||||
im = Image.new("RGBA", (S, S), (0, 0, 0, 255))
|
||||
d = ImageDraw.Draw(im)
|
||||
c = S / 2.0
|
||||
|
||||
# —— 时间线 ——
|
||||
pop = clamp01((i - 1) / 11.0) # 猫头弹入 1..12
|
||||
blink = 18 <= i <= 20 or 34 <= i <= 35
|
||||
happy = 44 <= i <= 47
|
||||
idle = i >= 12
|
||||
bob = math.sin((i - 12) / 6.2) * S * 0.012 if idle else 0.0
|
||||
tilt = math.sin((i - 12) / 9.0) * 3.2 if idle else 0.0
|
||||
ear_k = 1.0 + (0.22 if i in (28, 29, 30, 39, 40) else 0.0)
|
||||
|
||||
# 背景微光(让黑底不那么空)
|
||||
glow_r = S * (0.30 + 0.02 * math.sin(i / 5.0))
|
||||
for k in range(9, 0, -1):
|
||||
rr = glow_r * k / 9.0
|
||||
a = int(6 + 3 * (9 - k))
|
||||
d.ellipse([c - rr, c - rr * 1.05 + bob, c + rr, c + rr * 1.05 + bob], fill=(60, 40, 52, a))
|
||||
|
||||
# —— 猫头 ——
|
||||
if pop > 0:
|
||||
head_px = int(S * 0.58)
|
||||
eye = "closed" if blink else ("happy" if happy else "open")
|
||||
cat = cat_head(head_px, eye=eye, mouth="open" if happy else "w", ear_h=ear_k)
|
||||
sc = 0.55 + 0.45 * ease_out_back(pop)
|
||||
if abs(sc - 1.0) > 1e-3:
|
||||
ns = max(4, int(head_px * sc))
|
||||
cat = cat.resize((ns, ns), Image.LANCZOS)
|
||||
if abs(tilt) > 0.2:
|
||||
cat = cat.rotate(tilt, resample=Image.BICUBIC, expand=False)
|
||||
cy = c - S * 0.17 + bob
|
||||
im.alpha_composite(cat, (int(c - cat.width / 2), int(cy - cat.height / 2)))
|
||||
|
||||
|
||||
# —— 文字「哈基米」 ——
|
||||
glyphs, gap, th = text_parts(int(S * 0.135))
|
||||
total_w = sum(g.width for g in glyphs) + gap * (len(glyphs) - 1)
|
||||
ty = c + S * 0.185 + bob * 0.7
|
||||
gx = c - total_w / 2.0
|
||||
for idx, g in enumerate(glyphs):
|
||||
start = 14 + idx * 3
|
||||
p = clamp01((i - start) / 6.0)
|
||||
if p <= 0:
|
||||
gx += g.width + gap
|
||||
continue
|
||||
k = ease_out_back(p, 2.6)
|
||||
scale = 0.55 + 0.45 * k
|
||||
part = g
|
||||
if abs(scale - 1.0) > 1e-3:
|
||||
part = g.resize((max(2, int(g.width * scale)), max(2, int(g.height * scale))), Image.LANCZOS)
|
||||
# 粉色光晕
|
||||
halo = Image.new("RGBA", (part.width + 12, part.height + 12), (0, 0, 0, 0))
|
||||
ImageDraw.Draw(halo).ellipse([0, 0, halo.width - 1, halo.height - 1], fill=(255, 170, 196, 34))
|
||||
im.alpha_composite(halo, (int(gx - 6), int(ty + (th - part.height) / 2 - 6)))
|
||||
im.alpha_composite(part, (int(gx + (g.width - part.width) / 2), int(ty + (th - part.height) / 2)))
|
||||
gx += g.width + gap
|
||||
|
||||
# 下划线扫光
|
||||
if i >= 24:
|
||||
p = ease_out(clamp01((i - 24) / 10.0))
|
||||
y = c + S * 0.40 + bob * 0.7
|
||||
half = S * 0.17 * p
|
||||
d.line([(c - half, y), (c + half, y)], fill=(255, 220, 232, 200), width=max(2, int(S * 0.004)))
|
||||
|
||||
# —— 飘浮的爱心与爪印 ——
|
||||
for n in range(7):
|
||||
born = 22 + n * 3
|
||||
life = clamp01((i - born) / 26.0)
|
||||
if life <= 0 or life >= 1:
|
||||
continue
|
||||
a = int(200 * (1 - life) ** 1.2)
|
||||
if a <= 4:
|
||||
continue
|
||||
ang = -0.8 + n * 0.27
|
||||
dist = S * (0.30 + 0.16 * life)
|
||||
px = c + math.cos(ang) * dist
|
||||
py = c - S * 0.02 - dist * 0.85 - S * 0.10 * life
|
||||
sz = int(S * (0.026 + 0.008 * (n % 3)))
|
||||
if n % 3 == 0:
|
||||
sp = paw(sz, (255, 236, 242, a))
|
||||
else:
|
||||
sp = heart(sz, (255, 170, 190, a))
|
||||
im.alpha_composite(sp, (int(px), int(py)))
|
||||
|
||||
# —— 收尾淡出(与原动画结尾呼应) ——
|
||||
if i > 54:
|
||||
f = 1 - (i - 54) / 8.0 * 0.75
|
||||
im = Image.blend(Image.new("RGBA", im.size, (0, 0, 0, 255)), im, max(0.0, f))
|
||||
|
||||
return im.resize((W, W), Image.LANCZOS).convert("RGB")
|
||||
|
||||
|
||||
def make_gif(path):
|
||||
frames = [frame(i) for i in range(FRAMES)]
|
||||
# 统一调色板,避免逐帧偏色与闪烁
|
||||
pal_src = frames[len(frames) // 2].copy()
|
||||
for f in frames[::7]:
|
||||
pal_src = Image.blend(pal_src, f, 0.5) if pal_src.size == f.size else pal_src
|
||||
pal = pal_src.quantize(colors=200, method=Image.MEDIANCUT, dither=Image.NONE)
|
||||
pframes = [f.quantize(palette=pal, dither=Image.NONE) for f in frames]
|
||||
pframes[0].save(path, save_all=True, append_images=pframes[1:], duration=FRAME_MS,
|
||||
loop=1, optimize=True, disposal=1)
|
||||
return frames
|
||||
|
||||
|
||||
def make_logo(path, size):
|
||||
im = Image.new("RGBA", (size, size), (0, 0, 0, 0))
|
||||
d = ImageDraw.Draw(im)
|
||||
cat = cat_head(int(size * 0.74), eye="happy", mouth="w")
|
||||
im.alpha_composite(cat, ((size - cat.width) // 2, int(size * 0.02)))
|
||||
glyphs, gap, th = text_layer("哈基米", int(size * 0.215), color=(255, 255, 255, 255))
|
||||
total_w = sum(g.width for g in glyphs) + gap * (len(glyphs) - 1)
|
||||
x = (size - total_w) // 2
|
||||
for g in glyphs:
|
||||
im.alpha_composite(g, (x, int(size * 0.70)))
|
||||
x += g.width + gap
|
||||
im.save(path)
|
||||
|
||||
|
||||
def main():
|
||||
out = sys.argv[2] if len(sys.argv) > 2 else "out/splash"
|
||||
os.makedirs(out, exist_ok=True)
|
||||
frames = make_gif(os.path.join(out, "splash.gif"))
|
||||
make_logo(os.path.join(out, "game-logo.png"), 256)
|
||||
make_logo(os.path.join(out, "game-logo-HD.png"), 512)
|
||||
gif = os.path.join(out, "splash.gif")
|
||||
print(" splash.gif %dx%d %d 帧 %dms/帧 %.0f KB" % (W, W, FRAMES, FRAME_MS, os.path.getsize(gif) / 1024))
|
||||
for n in ("game-logo.png", "game-logo-HD.png"):
|
||||
print(" %-10s %.1f KB" % (n, os.path.getsize(os.path.join(out, n)) / 1024))
|
||||
# 自检:非黑像素占比
|
||||
import numpy as np
|
||||
cov = [float((np.array(f.convert("L")) > 24).mean()) for f in frames]
|
||||
print(" 内容占比 首帧 %.1f%% 中段 %.1f%% 末帧 %.1f%%" % (cov[0] * 100, cov[FRAMES // 2] * 100, cov[-1] * 100))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.gm;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.RectF;
|
||||
import android.view.View;
|
||||
|
||||
/**
|
||||
* 哈基米吉祥物:纯 Canvas 手绘的小白猫,不依赖任何图片资源(本游戏 assets 里没有贴图,全靠热更下载)。
|
||||
* 画的坐标系是 [-50, 50],绘制时缩放到控件大小。
|
||||
*/
|
||||
public class Hachimi extends View {
|
||||
|
||||
private final Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
private float t = 0f;
|
||||
private boolean anim = true;
|
||||
private float scale = 1f; // 额外放大倍数
|
||||
|
||||
public Hachimi(Context c) {
|
||||
super(c);
|
||||
p.setStyle(Paint.Style.FILL);
|
||||
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||
}
|
||||
|
||||
public void setBig(boolean big) { scale = big ? 1.7f : 1f; invalidate(); }
|
||||
|
||||
public void setAnim(boolean on) { anim = on; if (on) invalidate(); }
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas c) {
|
||||
int w = getWidth(), h = getHeight();
|
||||
if (w <= 0 || h <= 0) return;
|
||||
float s = Math.min(w, h) / 100f * scale;
|
||||
float bob = anim ? (float) Math.sin(t) * 1.8f : 0f;
|
||||
|
||||
c.save();
|
||||
c.translate(w / 2f, h / 2f + bob * s * 0.6f);
|
||||
c.scale(s, s);
|
||||
|
||||
// ---- 耳朵 ----
|
||||
p.setColor(0xFFFDFBF6);
|
||||
p.setStyle(Paint.Style.FILL);
|
||||
c.drawPath(tri(-30, -10, -12, -34, -4, -12), p);
|
||||
c.drawPath(tri(30, -10, 12, -34, 4, -12), p);
|
||||
p.setColor(0xFFFFB3C1);
|
||||
c.drawPath(tri(-25, -12, -14, -28, -9, -13), p);
|
||||
c.drawPath(tri(25, -12, 14, -28, 9, -13), p);
|
||||
|
||||
// ---- 脸 ----
|
||||
p.setColor(0xFFFDFBF6);
|
||||
p.setStyle(Paint.Style.FILL);
|
||||
c.drawCircle(0, 4, 27, p);
|
||||
p.setStyle(Paint.Style.STROKE);
|
||||
p.setStrokeWidth(1.6f);
|
||||
p.setColor(0xFFE7DCCD);
|
||||
c.drawCircle(0, 4, 27, p);
|
||||
p.setStyle(Paint.Style.FILL);
|
||||
|
||||
// ---- 腮红 ----
|
||||
p.setColor(0x33FF7A98);
|
||||
c.drawOval(new RectF(-22, 6, -10, 14), p);
|
||||
c.drawOval(new RectF(10, 6, 22, 14), p);
|
||||
|
||||
// ---- 眼睛 ----
|
||||
p.setColor(0xFF2B2B2B);
|
||||
c.drawOval(new RectF(-14, -8, -6, 4), p);
|
||||
c.drawOval(new RectF(6, -8, 14, 4), p);
|
||||
p.setColor(0xFFFFFFFF);
|
||||
c.drawCircle(-12.2f, -4.5f, 1.5f, p);
|
||||
c.drawCircle(7.8f, -4.5f, 1.5f, p);
|
||||
|
||||
// ---- 鼻子 + 嘴(ω)----
|
||||
p.setColor(0xFFFF9AA2);
|
||||
c.drawPath(tri(-2.4f, 8, 2.4f, 8, 0, 11.4f), p);
|
||||
|
||||
p.setStyle(Paint.Style.STROKE);
|
||||
p.setStrokeWidth(1.5f);
|
||||
p.setColor(0xFF6B6157);
|
||||
Path m = new Path();
|
||||
m.moveTo(0, 11.4f);
|
||||
m.lineTo(0, 14f);
|
||||
m.moveTo(0, 14f);
|
||||
m.quadTo(-3.4f, 18.5f, -6.6f, 14.2f);
|
||||
m.moveTo(0, 14f);
|
||||
m.quadTo(3.4f, 18.5f, 6.6f, 14.2f);
|
||||
c.drawPath(m, p);
|
||||
|
||||
// ---- 胡须 ----
|
||||
p.setStrokeWidth(1.2f);
|
||||
p.setColor(0xFFCFC5B8);
|
||||
c.drawLine(-16, 12, -30, 9, p);
|
||||
c.drawLine(-16, 15, -30, 16, p);
|
||||
c.drawLine(16, 12, 30, 9, p);
|
||||
c.drawLine(16, 15, 30, 16, p);
|
||||
|
||||
c.restore();
|
||||
|
||||
if (anim) {
|
||||
t += 0.14f;
|
||||
if (t > 1e6f) t = 0f;
|
||||
postInvalidateDelayed(50);
|
||||
}
|
||||
}
|
||||
|
||||
private static Path tri(float x1, float y1, float x2, float y2, float x3, float y3) {
|
||||
Path path = new Path();
|
||||
path.moveTo(x1, y1);
|
||||
path.lineTo(x2, y2);
|
||||
path.lineTo(x3, y3);
|
||||
path.close();
|
||||
return path;
|
||||
}
|
||||
}
|
||||
+138
-2
@@ -5,6 +5,8 @@ import android.app.AlertDialog;
|
||||
import android.app.Application;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.SharedPreferences;
|
||||
import android.media.AudioManager;
|
||||
import android.media.ToneGenerator;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.text.InputType;
|
||||
@@ -46,6 +48,19 @@ public class Panel {
|
||||
static final String GM_PREFS = "gm_prefs";
|
||||
static final String ZH_PO = "translations/chinese.po";
|
||||
|
||||
// ---- 哈基米吉祥物 ----
|
||||
static Hachimi cat;
|
||||
static FrameLayout.LayoutParams clp;
|
||||
static TextView bubble;
|
||||
static boolean catBig, catOn = true;
|
||||
static android.os.Handler ui;
|
||||
static ToneGenerator tone;
|
||||
static int meowIdx;
|
||||
static final String[] MEOWS = {
|
||||
"哈基米!", "哈基米哈基米~", "喵?", "胖宝宝~", "哈基米要飞啦",
|
||||
"喵喵喵喵喵", "让我开一局", "摔了也没事喵", "哈基米币给我一点", "摸摸头"
|
||||
};
|
||||
|
||||
// ---------------- 启动 ----------------
|
||||
public static void install(Application app) {
|
||||
app.registerActivityLifecycleCallbacks(new Application.ActivityLifecycleCallbacks() {
|
||||
@@ -147,6 +162,47 @@ public class Panel {
|
||||
}
|
||||
});
|
||||
|
||||
// ===== 哈基米吉祥物(纯 Canvas 画的小白猫,不依赖任何贴图)=====
|
||||
ui = new android.os.Handler(android.os.Looper.getMainLooper());
|
||||
catOn = gmsp().getBoolean("cat_on", true);
|
||||
catBig = gmsp().getBoolean("cat_big", false);
|
||||
cat = new Hachimi(act);
|
||||
cat.setBig(catBig);
|
||||
final int csz = dp(76);
|
||||
clp = new FrameLayout.LayoutParams(csz, csz);
|
||||
clp.gravity = android.view.Gravity.BOTTOM | android.view.Gravity.LEFT;
|
||||
clp.leftMargin = dp(10);
|
||||
clp.bottomMargin = dp(26);
|
||||
act.addContentView(cat, clp);
|
||||
cat.setVisibility(catOn ? View.VISIBLE : View.GONE);
|
||||
|
||||
final float[] cdown = new float[2], cstart = new float[2];
|
||||
final boolean[] cmoved = new boolean[1];
|
||||
cat.setOnTouchListener(new View.OnTouchListener() {
|
||||
public boolean onTouch(View v, MotionEvent e) {
|
||||
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) v.getLayoutParams();
|
||||
switch (e.getActionMasked()) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
cdown[0] = e.getRawX(); cdown[1] = e.getRawY();
|
||||
cstart[0] = lp.leftMargin; cstart[1] = lp.bottomMargin;
|
||||
cmoved[0] = false; return true;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
float dx = e.getRawX() - cdown[0], dy = e.getRawY() - cdown[1];
|
||||
if (Math.abs(dx) > dp(8) || Math.abs(dy) > dp(8)) cmoved[0] = true;
|
||||
lp.leftMargin = (int) (cstart[0] + dx);
|
||||
lp.bottomMargin = (int) (cstart[1] - dy);
|
||||
clampCat(lp);
|
||||
v.setLayoutParams(lp);
|
||||
if (bubble != null && bubble.getVisibility() == View.VISIBLE) hideBubble();
|
||||
return true;
|
||||
case MotionEvent.ACTION_UP:
|
||||
if (!cmoved[0]) { meow(); say(MEOWS[meowIdx++ % MEOWS.length]); }
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// 面板
|
||||
root = new LinearLayout(act);
|
||||
root.setOrientation(LinearLayout.VERTICAL);
|
||||
@@ -157,7 +213,7 @@ public class Panel {
|
||||
LinearLayout head = new LinearLayout(act);
|
||||
head.setOrientation(LinearLayout.HORIZONTAL);
|
||||
TextView t = new TextView(act);
|
||||
t.setText("登山赛车 GM v9");
|
||||
t.setText("登山赛车 GM v13 🐱");
|
||||
t.setTextColor(Color.WHITE);
|
||||
t.setTextSize(17);
|
||||
t.setPadding(dp(4), 0, 0, dp(4));
|
||||
@@ -227,6 +283,15 @@ public class Panel {
|
||||
btn("导出全部键值", new Runnable() { public void run() { exportAll(); } });
|
||||
btn("搜索键…", new Runnable() { public void run() { dialogSearch(); } });
|
||||
|
||||
// ===== 哈基米 =====
|
||||
section("哈基米");
|
||||
btn("哈基米 出现 / 隐藏", new Runnable() { public void run() { catToggle(); } });
|
||||
btn("哈基米 喵一声", new Runnable() { public void run() { meow(); say(MEOWS[meowIdx++ % MEOWS.length]); } });
|
||||
btn("哈基米 说句话", new Runnable() { public void run() { say(MEOWS[meowIdx++ % MEOWS.length]); } });
|
||||
btn("哈基米 变大 / 变回", new Runnable() { public void run() { catBig = !catBig; if (cat != null) cat.setBig(catBig); gmsp().edit().putBoolean("cat_big", catBig).commit(); toast(catBig ? "哈基米变大了" : "哈基米变回小只"); } });
|
||||
btn("哈基米币 +1 亿(就是金币)", new Runnable() { public void run() { addNum("coins", 100000000); say("哈基米币给你了喵"); } });
|
||||
btn("哈基米钻石 +1 万(就是宝石)", new Runnable() { public void run() { addNum("gems", 10000); say("亮闪闪的喵"); } });
|
||||
|
||||
// ===== 语言 =====
|
||||
section("语言");
|
||||
btn("游戏改简体中文(并保持)", new Runnable() { public void run() { forceZh(true); } });
|
||||
@@ -260,10 +325,81 @@ public class Panel {
|
||||
act.addContentView(root, rlp);
|
||||
updatePanelPos();
|
||||
|
||||
log("panel v9 built");
|
||||
log("panel v13 built");
|
||||
refresh();
|
||||
}
|
||||
|
||||
|
||||
// ---------------- 哈基米 ----------------
|
||||
static void clampCat(FrameLayout.LayoutParams lp) {
|
||||
int pw = 1080, ph = 1920;
|
||||
try {
|
||||
View parent = (View) cat.getParent();
|
||||
if (parent != null) { pw = parent.getWidth(); ph = parent.getHeight(); }
|
||||
} catch (Throwable t) {}
|
||||
int sz = dp(76);
|
||||
if (lp.leftMargin < -dp(6)) lp.leftMargin = -dp(6);
|
||||
if (lp.leftMargin > pw - sz + dp(6)) lp.leftMargin = pw - sz + dp(6);
|
||||
if (lp.bottomMargin < dp(4)) lp.bottomMargin = dp(4);
|
||||
if (lp.bottomMargin > ph - sz) lp.bottomMargin = ph - sz;
|
||||
}
|
||||
|
||||
static void catToggle() {
|
||||
if (cat == null) return;
|
||||
catOn = !catOn;
|
||||
cat.setVisibility(catOn ? View.VISIBLE : View.GONE);
|
||||
if (bubble != null) bubble.setVisibility(View.GONE);
|
||||
gmsp().edit().putBoolean("cat_on", catOn).commit();
|
||||
toast(catOn ? "哈基米来了喵" : "哈基米躲起来了");
|
||||
log("cat visible=" + catOn);
|
||||
}
|
||||
|
||||
/** 说话气泡:贴在猫头顶,1.8 秒后自动消失 */
|
||||
static void say(String text) {
|
||||
if (act == null || cat == null) return;
|
||||
try {
|
||||
hideBubble();
|
||||
bubble = new TextView(act);
|
||||
bubble.setText(text);
|
||||
bubble.setTextColor(0xFF222222);
|
||||
bubble.setTextSize(13);
|
||||
bubble.setPadding(dp(10), dp(5), dp(10), dp(5));
|
||||
GradientDrawable d = new GradientDrawable();
|
||||
d.setColor(0xF2FFFFFF);
|
||||
d.setCornerRadius(dp(10));
|
||||
d.setStroke(dp(1), 0xFFFFB3C1);
|
||||
bubble.setBackground(d);
|
||||
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
lp.gravity = android.view.Gravity.BOTTOM | android.view.Gravity.LEFT;
|
||||
lp.leftMargin = Math.max(0, clp.leftMargin + dp(4));
|
||||
lp.bottomMargin = clp.bottomMargin + dp(78);
|
||||
act.addContentView(bubble, lp);
|
||||
ui.postDelayed(new Runnable() { public void run() { hideBubble(); } }, 1800);
|
||||
log("hachimi say: " + text);
|
||||
} catch (Throwable t) { log("say error: " + t); }
|
||||
}
|
||||
|
||||
static void hideBubble() {
|
||||
try {
|
||||
if (bubble != null) {
|
||||
ViewGroup par = (ViewGroup) bubble.getParent();
|
||||
if (par != null) par.removeView(bubble);
|
||||
bubble = null;
|
||||
}
|
||||
} catch (Throwable t) {}
|
||||
}
|
||||
|
||||
/** 喵叫:手搓三声短音(不用音频资源,走 ToneGenerator) */
|
||||
static void meow() {
|
||||
try {
|
||||
if (tone == null) tone = new ToneGenerator(AudioManager.STREAM_MUSIC, 70);
|
||||
tone.startTone(ToneGenerator.TONE_PROP_BEEP, 90);
|
||||
ui.postDelayed(new Runnable() { public void run() { tone.startTone(ToneGenerator.TONE_PROP_BEEP2, 110); } }, 110);
|
||||
ui.postDelayed(new Runnable() { public void run() { tone.startTone(ToneGenerator.TONE_CDMA_PIP, 140); } }, 240);
|
||||
} catch (Throwable t) { log("meow error: " + t); }
|
||||
}
|
||||
|
||||
static void section(String name) {
|
||||
TextView h = new TextView(act);
|
||||
h.setText("— " + name + " —");
|
||||
|
||||
Reference in new issue
Block a user