Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.
Swift apple-siliconcustom-formathomebrewiosipaipadipadosiphonemetalnative-portnintendo-switchnxnativeromfsswitch-games
README: the logo on top, and the banner in the launcher's own look
v0lumehi2d3f20ce206c
diff --git a/README.md b/README.mdindex ba990fea..7d9abca0 100644--- a/README.md+++ b/README.md@@ -1,6 +1,9 @@<div align="center">-# NX2Apple+<picture>+ <source media="(prefers-color-scheme: dark)" srcset="frontend/screenshots/logo-dark.png">+ <img src="frontend/screenshots/logo-light.png" width="360" alt="NX2Apple, by nxnative">+</picture>**Your Switch games, running on your iPhone.**diff --git a/README.zh-CN.md b/README.zh-CN.mdindex c35d1890..b3001d8d 100644--- a/README.zh-CN.md+++ b/README.zh-CN.md@@ -1,6 +1,9 @@<div align="center">-# NX2Apple+<picture>+ <source media="(prefers-color-scheme: dark)" srcset="frontend/screenshots/logo-dark.png">+ <img src="frontend/screenshots/logo-light.png" width="360" alt="NX2Apple, by nxnative">+</picture>**你的 Switch 游戏,跑在你的 iPhone 上。**diff --git a/frontend/screenshots/gen_hero.py b/frontend/screenshots/gen_hero.pyindex 0bff349e..f34be052 100644--- a/frontend/screenshots/gen_hero.py+++ b/frontend/screenshots/gen_hero.py@@ -1,21 +1,27 @@# -*- coding: utf-8 -*--"""README hero: a 3:1 wide feature banner."""+"""README art in the launcher's own look: the feature banner (English and Chinese) and the logo.++ python3 frontend/screenshots/gen_hero.py++Drawn as HTML with the app's font (frontend/fonts/Manrope.ttf), palette (LauncherPalette in+LauncherView.swift) and icon, and rendered by headless Google Chrome at 2x. Chinese falls back to+PingFang SC, which macOS ships. The numbers are read from the tree on every run, so the banner and+the README cannot disagree.+"""+import html+import subprocess+import sys+import tempfilefrom 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"+HERE = Path(__file__).resolve().parent+REPO = HERE.parents[1]+CHROME = "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"-# ---- 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.- """+ """(game profiles, verified on an iPhone): the dm/games/0100… folders, and README.md's games+ table rows that say they were verified."""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()@@ -23,71 +29,125 @@ def repo_numbers() -> tuple[int, int]: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)-def med(s): return ImageFont.truetype(F_MED, s)--GREEN = (52, 199, 89)-YELLOW = (255, 214, 10)-GREY = (170, 180, 190)-CARD = (34, 41, 48)-CARD_EDGE = (58, 68, 78)---def vgrad(size, top, bottom):- w, h = size- base = Image.new("RGB", size)- d = ImageDraw.Draw(base)- for y in range(h):- t = y / (h - 1)- d.line([(0, y), (w, y)], fill=(- int(top[0] + (bottom[0] - top[0]) * t),- int(top[1] + (bottom[1] - top[1]) * t),- int(top[2] + (bottom[2] - top[2]) * t)))- return base---im = vgrad((W, H), (26, 32, 38), (15, 20, 24)).convert("RGBA")-d = ImageDraw.Draw(im, "RGBA")--for cx, cy, r, a in [(50, 40, 120, 20), (W - 60, 60, 90, 16), (40, H - 40, 90, 14), (W - 50, H - 50, 120, 18)]:- d.ellipse([cx - r, cy - r, cx + r, cy + r], outline=(255, 255, 255, a), width=3)--# ---- left column -----LX = 86-d.text((LX, 96), "Switch 游戏", font=hei(84), fill="white")-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)--_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- d.text((x, y0), num, font=hei(66), fill=color)- d.text((x + 2, y0 + 82), label, font=med(27), fill=(196, 206, 214))--# ---- right column: 2x2 cards -----RX = 900-CW = W - 90 - RX-CH = 132-GAP = 20-cards = [- ("01", "一键构建", "选好文件按构建,全程无命令行"),- ("02", "RomFS 归档", "30 万文件压成 127 片,16 GB 也能装"),- ("03", "断点续传", "中断接着跑,没变的部分直接复用"),- ("04", "自助安装", "自动下载仓库,App 自己也能更新"),-]-top = (H - (len(cards) * CH + (len(cards) - 1) * GAP)) // 2-for i, (num, title, desc) in enumerate(cards):- x = RX- y = top + i * (CH + GAP)- d.rounded_rectangle([x, y, x + CW, y + CH], radius=20, fill=CARD, outline=CARD_EDGE, width=2)- d.text((x + 28, y + 22), num, font=hei(42), fill=GREEN)- d.text((x + 104, y + 16), title, font=hei(34), fill="white")- d.text((x + 104, y + 66), desc, font=med(25), fill=GREY)--im.convert("RGB").save(OUT, optimize=True)-print("saved", OUT, Image.open(OUT).size, "ratio", round(W / H, 2))++TEXT = {+ 'en': {+ 'out': 'hero-features-en.png',+ 'title': ('Switch games,', 'on your iPhone.'),+ 'lead': 'Not an emulator. No terminal.<br>A Mac app does the whole build in a few clicks.',+ 'stats': ['game profiles', 'verified on iPhone', 'files → 127 shards'],+ 'cards': [+ ('One-click build', 'Pick your files, press Build. No terminal.'),+ ('RomFS archive', '300k files in 127 shards: a 16 GB game installs.'),+ ('Resumable builds', 'A stopped build continues where it left off.'),+ ('Self-installing', 'Fetches the build tools and updates itself.'),+ ],+ },+ 'zh': {+ 'out': 'hero-features.png',+ 'title': ('Switch 游戏,', '装进 iPhone。'),+ 'lead': '不是模拟器 · 不用命令行<br>一个 macOS App 点几下就完成构建',+ 'stats': ['款游戏 profile', '款 iPhone 实测', '文件 → 127 分片'],+ 'cards': [+ ('一键构建', '选好文件按构建,全程无命令行'),+ ('RomFS 归档', '30 万文件压成 127 片,16 GB 也能装'),+ ('断点续传', '中断接着跑,没变的部分直接复用'),+ ('自助安装', '自动下载仓库,App 自己也能更新'),+ ],+ },+}++STYLE = """+@font-face { font-family: Manrope; src: url('%(font)s'); font-weight: 200 800; }+* { margin: 0; box-sizing: border-box; }+html, body { width: %(w)dpx; height: %(h)dpx; overflow: hidden; background: transparent; }+body { font-family: Manrope, 'PingFang SC', sans-serif; color: #fff; -webkit-font-smoothing: antialiased; }+.cream { background: linear-gradient(180deg, #fff6e6 0%%, #ffe2b8 100%%); -webkit-background-clip: text; color: transparent; }+.mark { display: flex; align-items: center; gap: 11px; }+.mark img { width: 34px; height: 34px; }+.mark b { font-size: 21px; font-weight: 700; letter-spacing: -0.6px; }+.mark i { font-style: normal; font-size: 9px; font-weight: 500; color: rgba(255,255,255,.5); display: block; margin-top: -3px; }+"""++BANNER = """<!doctype html><meta charset="utf-8"><style>%(style)s+body { background: #0e0e0f; }+.glow { position: absolute; inset: 0;+ background: radial-gradient(520px 300px at 18%% 30%%, rgba(255,226,184,.10), transparent 70%%),+ radial-gradient(420px 260px at 92%% 110%%, rgba(64,214,120,.06), transparent 70%%); }+.left { position: absolute; left: 46px; top: 30px; width: 440px; }+h1 { margin-top: 22px; font-size: 42px; line-height: 1.04; font-weight: 800; letter-spacing: -1.6px; }+.lead { margin-top: 10px; font-size: 14px; line-height: 1.5; font-weight: 500; color: rgba(255,255,255,.62); }+.stats { position: absolute; left: 46px; bottom: 30px; display: flex; gap: 34px; }+.stat b { display: block; font-size: 26px; font-weight: 800; letter-spacing: -1px; }+.stat span { display: flex; align-items: center; gap: 6px; margin-top: 2px; font-size: 10px; font-weight: 700;+ letter-spacing: 1.1px; text-transform: var(--case, uppercase); color: rgba(255,255,255,.55); }+.stat span::before { content: ''; width: 6px; height: 6px; border-radius: 3px; background: var(--dot); }+.cards { position: absolute; right: 40px; top: 38px; bottom: 38px; width: 480px;+ display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 12px; }+.card { position: relative; padding: 20px 20px 18px; border-radius: 16px; background: #1a1a1c;+ border: 1px solid rgba(255,255,255,.08); overflow: hidden; display: flex; flex-direction: column; }+.card::after { content: ''; position: absolute; inset: 0; border-radius: 16px; pointer-events: none;+ background: linear-gradient(160deg, rgba(255,255,255,.05), transparent 45%%); }+.num { align-self: flex-start; padding: 3px 9px; border-radius: 99px; font-size: 10px; font-weight: 800;+ letter-spacing: 1px; color: #0e0e0f; background: #fff0d6; }+.card h2 { margin-top: 14px; font-size: 18px; font-weight: 700; letter-spacing: -0.4px; }+.card p { margin-top: 5px; font-size: 12.5px; text-wrap: pretty; line-height: 1.45; font-weight: 500; color: rgba(255,255,255,.55); }+</style>+<div class="glow"></div>+<div class="left">+ <div class="mark"><img src="%(icon)s"><div><b>NX2Apple</b><i>— by nxnative</i></div></div>+ <h1>%(t1)s<br><span class="cream">%(t2)s</span></h1>+ <p class="lead">%(lead)s</p>+</div>+<div class="stats" style="--case: %(case)s">%(stats)s</div>+<div class="cards">%(cards)s</div>+"""++LOGO = """<!doctype html><meta charset="utf-8"><style>%(style)s+body { display: flex; align-items: center; justify-content: center; }+.mark { gap: 18px; }+.mark img { width: 72px; height: 72px; }+.mark b { font-size: 48px; letter-spacing: -1.6px; color: %(ink)s; }+.mark i { font-size: 15px; margin-top: -4px; color: %(sub)s; }+</style>+<div class="mark"><img src="%(icon)s"><div><b>NX2Apple</b><i>— by nxnative</i></div></div>+"""+++def render(page: str, out: Path, w: int, h: int) -> None:+ with tempfile.NamedTemporaryFile('w', suffix='.html', delete=False, encoding='utf-8') as f:+ f.write(page)+ subprocess.run([CHROME, '--headless=new', '--hide-scrollbars', '--force-device-scale-factor=2',+ '--default-background-color=00000000', f'--window-size={w},{h}',+ f'--screenshot={out}', f'file://{f.name}'],+ check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)+ Path(f.name).unlink()+ print('saved', out.relative_to(REPO))+++def main() -> int:+ if not Path(CHROME).exists():+ sys.exit('needs Google Chrome in /Applications (it renders the HTML)')+ common = {'font': (REPO / 'frontend/fonts/Manrope.ttf').as_uri(),+ 'icon': (REPO / 'frontend/icon.iconset/[email protected]').as_uri()}+ games, verified = repo_numbers()+ w, h = 1050, 350 # 2100x700 at 2x, the banner's old size+ for lang in TEXT.values():+ style = STYLE % {**common, 'w': w, 'h': h}+ nums = [(str(games), '#40d678'), (str(verified), '#ffc73d'), ('300k', '#fff0d6')]+ stats = ''.join(f'<div class="stat" style="--dot:{c}"><b>{n}</b><span>{html.escape(l)}</span></div>'+ for (n, c), l in zip(nums, lang['stats']))+ cards = ''.join(f'<div class="card"><span class="num">0{i + 1}</span><h2>{html.escape(t)}</h2><p>{html.escape(d)}</p></div>'+ for i, (t, d) in enumerate(lang['cards']))+ page = BANNER % {**common, 'style': style, 't1': lang['title'][0], 't2': lang['title'][1],+ 'lead': lang['lead'], 'stats': stats, 'cards': cards,+ 'case': 'uppercase' if lang is TEXT['en'] else 'none'}+ render(page, HERE / lang['out'], w, h)+ for name, ink, sub in [('logo-dark.png', '#ffffff', 'rgba(255,255,255,.5)'), ('logo-light.png', '#0e0e0f', 'rgba(14,14,15,.55)')]:+ style = STYLE % {**common, 'w': 420, 'h': 110}+ render(LOGO % {**common, 'style': style, 'ink': ink, 'sub': sub}, HERE / name, 420, 110)+ return 0+++if __name__ == '__main__':+ sys.exit(main())diff --git a/frontend/screenshots/gen_hero_en.py b/frontend/screenshots/gen_hero_en.pydeleted file mode 100644index 1bb382bd..00000000--- a/frontend/screenshots/gen_hero_en.py+++ /dev/null@@ -1,93 +0,0 @@-# -*- 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)-def med(s): return ImageFont.truetype(F_MED, s)--GREEN = (52, 199, 89)-YELLOW = (255, 214, 10)-GREY = (170, 180, 190)-CARD = (34, 41, 48)-CARD_EDGE = (58, 68, 78)---def vgrad(size, top, bottom):- w, h = size- base = Image.new("RGB", size)- d = ImageDraw.Draw(base)- for y in range(h):- t = y / (h - 1)- d.line([(0, y), (w, y)], fill=(- int(top[0] + (bottom[0] - top[0]) * t),- int(top[1] + (bottom[1] - top[1]) * t),- int(top[2] + (bottom[2] - top[2]) * t)))- return base---im = vgrad((W, H), (26, 32, 38), (15, 20, 24)).convert("RGBA")-d = ImageDraw.Draw(im, "RGBA")--for cx, cy, r, a in [(50, 40, 120, 20), (W - 60, 60, 90, 16), (40, H - 40, 90, 14), (W - 50, H - 50, 120, 18)]:- d.ellipse([cx - r, cy - r, cx + r, cy + r], outline=(255, 255, 255, a), width=3)--# ---- left column -----LX = 86-d.text((LX, 96), "Switch games", font=hei(84), fill="white")-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)--_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- d.text((x, y0), num, font=hei(66), fill=color)- d.text((x + 2, y0 + 82), label, font=med(27), fill=(196, 206, 214))--# ---- right column: 2x2 cards -----RX = 900-CW = W - 90 - RX-CH = 132-GAP = 20-cards = [- ("01", "One-click build", "Pick your files, press build — no terminal"),- ("02", "RomFS archive", "300k files into 127 shards — 16 GB installs"),- ("03", "Resumable builds", "A stopped build continues where it left off"),- ("04", "Self-installing", "Fetches the repository and updates itself"),-]-top = (H - (len(cards) * CH + (len(cards) - 1) * GAP)) // 2-for i, (num, title, desc) in enumerate(cards):- x = RX- y = top + i * (CH + GAP)- d.rounded_rectangle([x, y, x + CW, y + CH], radius=20, fill=CARD, outline=CARD_EDGE, width=2)- d.text((x + 28, y + 22), num, font=hei(42), fill=GREEN)- d.text((x + 104, y + 16), title, font=hei(34), fill="white")- d.text((x + 104, y + 66), desc, font=med(25), fill=GREY)--im.convert("RGB").save(OUT, optimize=True)-print("saved", OUT, Image.open(OUT).size, "ratio", round(W / H, 2))diff --git a/frontend/screenshots/hero-features-en.png b/frontend/screenshots/hero-features-en.pngindex 33e32ead..9147f5ba 100644Binary files a/frontend/screenshots/hero-features-en.png and b/frontend/screenshots/hero-features-en.png differdiff --git a/frontend/screenshots/hero-features.png b/frontend/screenshots/hero-features.pngindex 84fb8492..9162446d 100644Binary files a/frontend/screenshots/hero-features.png and b/frontend/screenshots/hero-features.png differdiff --git a/frontend/screenshots/logo-dark.png b/frontend/screenshots/logo-dark.pngnew file mode 100644index 00000000..dcd00160Binary files /dev/null and b/frontend/screenshots/logo-dark.png differdiff --git a/frontend/screenshots/logo-light.png b/frontend/screenshots/logo-light.pngnew file mode 100644index 00000000..f3425632Binary files /dev/null and b/frontend/screenshots/logo-light.png differ