Skip to content

Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.

README banners: read the counts from the tree instead of a hard-coded 58

LNPANDYfe363f9c9931
diff --git a/frontend/screenshots/gen_hero.py b/frontend/screenshots/gen_hero.py
index c22ac745..0bff349e 100644
--- a/frontend/screenshots/gen_hero.py
+++ b/frontend/screenshots/gen_hero.py
@@ -1,10 +1,28 @@
# -*- coding: utf-8 -*-
"""README hero: a 3:1 wide feature banner."""
+from pathlib import Path
from PIL import Image, ImageDraw, ImageFont
W, H = 2100, 700
OUT = "/Users/hejie/ZCodeProject/nxnative-romfs-archive/frontend/screenshots/hero-features.png"
+# ---- live numbers, so the banner cannot go stale again ----
+REPO = Path(__file__).resolve().parents[2]
+
+def repo_numbers() -> tuple[int, int]:
+ """(game profiles, verified on an iPhone) straight from the tree.
+
+ The profile count is the number of dm/games/0100… folders; the verified count is the rows
+ of README.md's games table that say so. Both are what the README's own text claims, so the
+ banner and the text can never disagree.
+ """
+ games = sum(1 for d in (REPO / 'dm/games').iterdir() if d.is_dir() and d.name.startswith('0100'))
+ readme = (REPO / 'README.md').read_text(encoding='utf-8')
+ verified = sum(1 for ln in readme.splitlines()
+ if ln.startswith('| ') and ln.count('`') >= 2
+ and ('**Verified here**' in ln or 'Verified —' in ln))
+ return games, verified
+
F_HEI = "/Library/Fonts/4080_方正超粗黑_GBK.ttf"
F_MED = "/Library/Fonts/SourceHanSansCN-Medium.ttf"
def hei(s): return ImageFont.truetype(F_HEI, s)
@@ -43,7 +61,8 @@ d.text((LX, 196), "装进 iPhone", font=hei(84), fill=YELLOW)
d.text((LX + 4, 308), "不是模拟器 · 不用命令行", font=med(38), fill=(206, 214, 222))
d.text((LX + 4, 358), "一个 macOS App 点几下就完成构建", font=med(34), fill=GREY)
-stats = [("58", "款游戏 profile", GREEN), ("3", "款 iPhone 实测", YELLOW), ("300k", "文件 → 127 分片", GREEN)]
+_games, _verified = repo_numbers()
+stats = [(str(_games), "款游戏 profile", GREEN), (str(_verified), "款 iPhone 实测", YELLOW), ("300k", "文件 → 127 分片", GREEN)]
y0 = 470
for i, (num, label, color) in enumerate(stats):
x = LX + i * 268
diff --git a/frontend/screenshots/gen_hero_en.py b/frontend/screenshots/gen_hero_en.py
index 7c67e9d4..1bb382bd 100644
--- a/frontend/screenshots/gen_hero_en.py
+++ b/frontend/screenshots/gen_hero_en.py
@@ -1,10 +1,28 @@
# -*- coding: utf-8 -*-
"""README hero: a 3:1 wide feature banner."""
+from pathlib import Path
from PIL import Image, ImageDraw, ImageFont
W, H = 2100, 700
OUT = "/Users/hejie/ZCodeProject/nxnative-romfs-archive/frontend/screenshots/hero-features-en.png"
+# ---- live numbers, so the banner cannot go stale again ----
+REPO = Path(__file__).resolve().parents[2]
+
+def repo_numbers() -> tuple[int, int]:
+ """(game profiles, verified on an iPhone) straight from the tree.
+
+ The profile count is the number of dm/games/0100… folders; the verified count is the rows
+ of README.md's games table that say so. Both are what the README's own text claims, so the
+ banner and the text can never disagree.
+ """
+ games = sum(1 for d in (REPO / 'dm/games').iterdir() if d.is_dir() and d.name.startswith('0100'))
+ readme = (REPO / 'README.md').read_text(encoding='utf-8')
+ verified = sum(1 for ln in readme.splitlines()
+ if ln.startswith('| ') and ln.count('`') >= 2
+ and ('**Verified here**' in ln or 'Verified —' in ln))
+ return games, verified
+
F_HEI = "/Library/Fonts/4080_方正超粗黑_GBK.ttf"
F_MED = "/Library/Fonts/SourceHanSansCN-Medium.ttf"
def hei(s): return ImageFont.truetype(F_HEI, s)
@@ -43,7 +61,8 @@ d.text((LX, 196), "on your iPhone", font=hei(84), fill=YELLOW)
d.text((LX + 4, 308), "Not an emulator. No terminal.", font=med(38), fill=(206, 214, 222))
d.text((LX + 4, 358), "A macOS app does the whole build in a few clicks", font=med(34), fill=GREY)
-stats = [("58", "game profiles", GREEN), ("3", "verified on iPhone", YELLOW), ("300k", "files → 127 shards", GREEN)]
+_games, _verified = repo_numbers()
+stats = [(str(_games), "game profiles", GREEN), (str(_verified), "verified on iPhone", YELLOW), ("300k", "files → 127 shards", GREEN)]
y0 = 470
for i, (num, label, color) in enumerate(stats):
x = LX + i * 268
diff --git a/frontend/screenshots/hero-features-en.png b/frontend/screenshots/hero-features-en.png
index 687383ee..54f6aa23 100644
Binary files a/frontend/screenshots/hero-features-en.png and b/frontend/screenshots/hero-features-en.png differ
diff --git a/frontend/screenshots/hero-features.png b/frontend/screenshots/hero-features.png
index 9f5b100d..3adf8623 100644
Binary files a/frontend/screenshots/hero-features.png and b/frontend/screenshots/hero-features.png differ
diff --git a/scripts/sync_upstream.py b/scripts/sync_upstream.py
index aaa6b796..3ed1e46f 100644
--- a/scripts/sync_upstream.py
+++ b/scripts/sync_upstream.py
@@ -779,6 +779,17 @@ def refresh_badges():
p.write_text(new, encoding='utf-8')
say(f' badge {name}: {value}')
say(f'badges: {games} games, {verified} verified')
+ # The README banners carry the same two numbers, so they are redrawn here: both scripts read
+ # them from the tree (repo_numbers()), so this only runs when the tree changed.
+ for script in ('frontend/screenshots/gen_hero.py', 'frontend/screenshots/gen_hero_en.py'):
+ sp = REPO / script
+ if not sp.exists():
+ continue
+ r = subprocess.run([sys.executable, str(sp)], capture_output=True, text=True, timeout=180)
+ if r.returncode == 0:
+ say(f' banner: {Path(script).name} redrawn')
+ else:
+ say(f' ! banner {Path(script).name} failed: {(r.stderr or "").strip()[:160]}')
def main():