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
Merge branch 'main' into test/win-engine-and-deps-fix
LNPANDY73aaf32985ba
diff --cc frontend-qt/nspb_qt/library.pyindex 6ee72159,00000000..84357279mode 100644,000000..100644--- a/frontend-qt/nspb_qt/library.py+++ b/frontend-qt/nspb_qt/library.py@@@ -1,1305 -1,0 +1,1310 @@@+"""Game library, Switch 2 folder/NUP scanner, artwork store, build-folder cleaner, game deletion, and drive copy.++Mirrors the Mac Swift launcher's Library.swift, GameFolder.swift, Artwork.swift,+FreeSpace.swift, GameDeletion.swift, and DriveCopy.swift for the Windows/Qt front end.+"""+from __future__ import annotations++import json+import os+import re+import shutil+import struct+import tempfile+import threading+import time+import urllib.request+from dataclasses import dataclass, field+from pathlib import Path+from typing import Callable++from . import platform_util as pu+++def default_state_dir() -> Path:+ env_dir = os.environ.get('NSPB_STATE_DIR')+ if env_dir:+ return Path(env_dir)+ if os.environ.get('QT_QPA_PLATFORM') == 'offscreen':+ return Path(tempfile.gettempdir()) / f'nspb-offscreen-{os.getpid()}'+ if pu.IS_WIN:+ root = Path(os.environ.get('LOCALAPPDATA') or (Path.home() / 'AppData' / 'Local'))+ return root / 'NS Port Builder'+ return Path.home() / 'Library' / 'Application Support' / 'NS Port Builder'++_TID_RE = re.compile(r'\[([0-9A-Fa-f]{16})\]')+_TID_ANY_RE = re.compile(r'(?<![0-9A-Fa-f])([0-9A-Fa-f]{16})(?![0-9A-Fa-f])')+_VER_TAG_RE = re.compile(r'\[v\d+\]', re.IGNORECASE)+_PAREN_TAG_RE = re.compile(r'\([^)]*\)')+_BRACKET_TAG_RE = re.compile(r'\[[^\]]*\]')+_KIND_SUFFIX_RE = re.compile(r'[-_\s]*(upd|update|base|dlc|patch)\s*$', re.IGNORECASE)++PACKAGE_EXTS = {'.nsp', '.xci', '.nsz', '.xcz'}++BUNDLED_ART: dict[str, str] = {+ '01007EF00011E000': 'docs/images/botw-2.png',+ '0100F2C0115B6000': 'docs/images/totk-2.png',+ '0100000000010000': 'docs/images/odyssey-2.png',+ '010028600EBDA000': 'docs/images/3dw-2.png',+ '0100152000022000': 'docs/images/mk8d-2.png',+ '01006A800016E000': 'docs/images/ssbu-2.png',+ '0100E95004038000': 'docs/images/xc2-1.png',+ '010074F013262000': 'docs/images/xc3-2.png',+ '0100453019AA8000': 'docs/images/xcx-1.png',+ '0100A3D008C5C000': 'docs/images/sv-1.png',+ '01001F5010DFA000': 'docs/images/pla-2.png',+ '01008F6008C5E000': 'docs/images/sword-1.png',+ '0100000011D90000': 'docs/images/bd-2.png',+ '0100F43008C44000': 'docs/images/fe-engage-1.png',+ '010055D009F78000': 'docs/images/fe3h-1.png',+ '010085000B772000': 'docs/images/feth-1.png',+ '0100D71004694000': 'docs/images/p5r-1.png',+ '0100A6301214E000': 'docs/images/smt5v-1.png',+ '010025C00D410000': 'docs/images/acnh-1.png',+ '0100626011656000': 'docs/images/dread-1.png',+ '0100C4B0034B2000': 'docs/images/mp-remastered-1.png',+ '010016501B772000': 'docs/images/mp4-1.png',+ '010049900F546000': 'docs/images/kirby-fl-2.png',+ '01004D300C5AE000': 'docs/images/krtdld-1.png',+ '01008CF01BAAC000': 'docs/images/zelda-eow-1.png',+ '01006BB00C6F0000': 'docs/images/la-1.png',+ '01002DA013484000': 'docs/images/sshd-1.png',+ '010028A017892000': 'docs/images/pikmin4-1.png',+ '0100A3900C3E2000': 'docs/images/pm-ttyd-1.png',+ '0100F8F0000A2000': 'docs/images/smbw-2.png',+ '01001B300B9BE000': 'docs/images/lm3-1.png',+ '0100C25013430000': 'docs/images/bayo3-1.png',+ '01004A400D244000': 'docs/images/astral-chain-1.png',+ '0100D870045B6000': 'docs/images/nier-1.png',+ '0100E2F017572000': 'docs/images/unicorn-1.png',+ '010057D00ECE4000': 'docs/images/octopath2-1.png',+ '0100E66010ADE000': 'docs/images/triangle-1.png',+ '0100B7D01605C000': 'docs/images/starocean2r-1.png',+ '01006C300E9F0000': 'docs/images/dq11s-1.png',+ '01006C1017892000': 'docs/images/dq3hd2d-1.png',+ '0100B04011742000': 'docs/images/mhr-2.png',+ '0100770008DD8000': 'docs/images/mhgu-1.png',+ '010010A01D54E000': 'docs/images/silksong-1.png',+ '0100633007D48000': 'docs/images/hk-1.png',+ '0100535012974000': 'docs/images/hades-1.png',+ '0100F7B00BB5C000': 'docs/images/celeste-1.png',+ '0100CD301A5C8000': 'docs/images/balatro-1.png',+ '01002E7016C46000': 'docs/images/dave-1.png',+ '010040600C5CE000': 'docs/images/cuphead-1.png',+ '0100E6500B9AC000': 'docs/images/dead-cells-1.png',+ '01006C900EC02000': 'docs/images/subnautica-1.png',+ '01000890195B8000': 'docs/images/pop-tlc-1.png',+ '0100B8E016F76000': 'docs/images/dredge-1.png',+ '0100C1F0051B6000': 'docs/images/factorio-1.png',+ '01003D20137F8000': 'docs/images/splatoon3-1.png',+ '0100B0C0115B8000': 'docs/images/sky-1.png',+ '01005CA01580E000': 'docs/images/diablo3-1.png',+ '0100C4C00A922000': 'docs/images/darksouls-1.png',+ '0100DE900C3E4000': 'docs/images/skyrim-1.png',+ '0100830004FB6000': 'docs/images/doom-1.png',+ '01003D100E9C6000': 'docs/images/witcher3-1.png',+}+++def format_bytes(size: int) -> str:+ if size <= 0:+ return '0 B'+ units = ['B', 'KB', 'MB', 'GB', 'TB']+ val = float(size)+ idx = 0+ while val >= 1024.0 and idx < len(units) - 1:+ val /= 1024.0+ idx += 1+ if idx == 0:+ return f'{int(val)} B'+ if val >= 100 or idx == 1:+ return f'{val:.0f} {units[idx]}'+ return f'{val:.1f} {units[idx]}'+++def clean_game_name(filename: str) -> str:+ stem = os.path.splitext(os.path.basename(filename))[0]+ s = _BRACKET_TAG_RE.sub('', stem)+ s = _PAREN_TAG_RE.sub('', s)+ s = _KIND_SUFFIX_RE.sub('', s)+ s = s.replace('_', ' ').strip(' -._')+ return s or stem+++def extract_title_id(path: str) -> str | None:+ name = os.path.basename(path)+ m = _TID_RE.search(name)+ if m:+ return m.group(1).upper()+ m2 = _TID_ANY_RE.search(name)+ if m2:+ return m2.group(1).upper()+ return None+++def base_family_id(tid: str) -> str:+ if len(tid) != 16:+ return tid.upper()+ try:+ val = int(tid, 16)+ return f'{val & ~0x1FFF:016X}'+ except ValueError:+ return tid.upper()+++def classify_tid(tid: str) -> str:+ """Return 'base', 'update', or 'dlc' based on low 12 bits of Title ID."""+ if len(tid) != 16:+ return 'base'+ try:+ low = int(tid, 16) & 0xFFF+ if low == 0x000:+ return 'base'+ if low == 0x800:+ return 'update'+ return 'dlc'+ except ValueError:+ return 'base'+++# ---------------------------------------------------------------------------+# Switch 2 GameFolder & NUP scanner (mirrors GameFolder.swift)+# ---------------------------------------------------------------------------++@dataclass+class GameFolderContents:+ folder: str+ title_id: int+ updates: list[tuple[int, str]] = field(default_factory=list)+ dlc: list[tuple[int, str]] = field(default_factory=list)+ nup: str | None = None++ @property+ def title_id_hex(self) -> str:+ return f'{self.title_id:016X}' if self.title_id else ''++ @property+ def base_path(self) -> str:+ return self.nup or os.path.join(self.folder, 'base')++ @property+ def script_input(self) -> str:+ return self.nup or self.folder++ @property+ def has_title_id(self) -> bool:+ return self.title_id != 0++ @property+ def newest_update(self) -> tuple[int, str] | None:+ return self.updates[-1] if self.updates else None+++@dataclass+class GameFolderProblem:+ kind: str # 'missing', 'noBaseFolder', 'unreadableNPDM', 'notBaseTitle', 'packageBeside', 'dlcName', 'notDLC', 'dlcRomFS', 'notNUP', 'nupPartial', 'severalNUPs'+ arg1: object = None+ arg2: object = None+++class GameFolder:+ @staticmethod+ def nup_files(folder: str) -> list[str]:+ try:+ entries = sorted(os.listdir(folder))+ except OSError:+ return []+ out = []+ for name in entries:+ if not name.startswith('._') and name.lower().endswith('.nup'):+ full = os.path.join(folder, name)+ if os.path.isfile(full):+ out.append(name)+ return out++ @staticmethod+ def is_candidate(path: str) -> bool:+ if not path:+ return False+ if path.lower().endswith('.nup') and os.path.isfile(path):+ return True+ if os.path.isfile(os.path.join(path, 'base', 'exefs', 'main.npdm')):+ return True+ if GameFolder.nup_files(path):+ return True+ return (+ os.path.isfile(os.path.join(path, 'exefs', 'main.npdm'))+ and not os.path.exists(os.path.join(path, 'base'))+ )++ @staticmethod+ def program_id(npdm_bytes: bytes) -> int | None:+ if len(npdm_bytes) < 0x78 or npdm_bytes[:4] != b'META':+ return None+ off, size = struct.unpack_from('<II', npdm_bytes, 0x70)+ if size < 0x18 or off + 0x18 > len(npdm_bytes):+ return None+ if npdm_bytes[off:off + 4] != b'ACI0':+ return None+ return struct.unpack_from('<Q', npdm_bytes, off + 0x10)[0]++ @staticmethod+ def read_nup(path: str) -> GameFolderContents | GameFolderProblem:+ name = os.path.basename(path)+ try:+ size = os.path.getsize(path)+ with open(path, 'rb') as f:+ head = f.read(0x80)+ if len(head) != 0x80 or head[:3] != b'NUP' or head[3] != 1:+ return GameFolderProblem('notNUP', name)+ expected_size = struct.unpack_from('<Q', head, 0x40)[0]+ if expected_size != size:+ return GameFolderProblem('nupPartial', name)+ toc = struct.unpack_from('<Q', head, 0x08)[0]+ count = struct.unpack_from('<I', head, 0x48)[0]+ if count <= 0 or count >= 100_000 or toc + 0x30 + count * 0x40 > size:+ return GameFolderProblem('notNUP', name)+ f.seek(toc)+ table = f.read(0x30 + count * 0x40)+ if len(table) != 0x30 + count * 0x40 or table[:4] != b'TOC\x01':+ return GameFolderProblem('notNUP', name)+ except OSError:+ return GameFolderProblem('notNUP', name)++ base = 0+ update_title = 0+ updates: list[tuple[int, str]] = []+ addons: list[int] = []+ for i in range(count):+ o = 0x30 + i * 0x40+ tid = struct.unpack_from('<Q', table, o)[0]+ ver = struct.unpack_from('<I', table, o + 20)[0]+ kind = table[o + 24]+ if kind == 0:+ base = tid+ elif kind == 1:+ updates.append((ver, path))+ if update_title == 0:+ update_title = tid & ~0xFFF+ elif kind == 2:+ addons.append(tid)+ app = base if (base != 0 and (base & 0xFFF) == 0) else update_title+ updates.sort(key=lambda x: x[0])+ addons.sort()+ return GameFolderContents(+ folder=os.path.dirname(path),+ title_id=app,+ updates=updates,+ dlc=[(t, path) for t in addons],+ nup=path,+ )++ @staticmethod+ def scan(folder: str) -> GameFolderContents | GameFolderProblem:+ if folder.lower().endswith('.nup') and os.path.isfile(folder):+ return GameFolder.read_nup(folder)+ try:+ top = sorted(os.listdir(folder))+ except OSError:+ return GameFolderProblem('missing', 'base/exefs/main.npdm')++ for name in top:+ if not name.startswith('._') and os.path.splitext(name)[1].lower() in PACKAGE_EXTS:+ if os.path.isfile(os.path.join(folder, name)):+ return GameFolderProblem('packageBeside', name)++ nups = GameFolder.nup_files(folder)+ if len(nups) > 1:+ return GameFolderProblem('severalNUPs', len(nups))+ if len(nups) == 1:+ return GameFolder.read_nup(os.path.join(folder, nups[0]))++ npdm_path = os.path.join(folder, 'base', 'exefs', 'main.npdm')+ if not os.path.isfile(npdm_path):+ if os.path.isfile(os.path.join(folder, 'exefs', 'main.npdm')) and not os.path.exists(os.path.join(folder, 'base')):+ return GameFolderProblem('noBaseFolder')+ return GameFolderProblem('missing', 'base/exefs/main.npdm')++ def subdirs(p: str) -> list[str]:+ if not os.path.isdir(p):+ return []+ try:+ return sorted(d for d in os.listdir(p) if not d.startswith('.') and os.path.isdir(os.path.join(p, d)))+ except OSError:+ return []++ updates_dir = os.path.join(folder, 'updates')+ versions = [v for v in subdirs(updates_dir) if v.isdigit()]+ has_romfs = os.path.isdir(os.path.join(folder, 'base', 'romfs')) or any(+ os.path.isdir(os.path.join(updates_dir, v, 'romfs')) for v in versions+ )+ if not has_romfs:+ return GameFolderProblem('missing', 'base/romfs')++ try:+ with open(npdm_path, 'rb') as f:+ data = f.read()+ except OSError:+ return GameFolderProblem('unreadableNPDM')++ app = GameFolder.program_id(data)+ if app is None:+ return GameFolderProblem('unreadableNPDM')+ if (app & 0xFFF) != 0:+ return GameFolderProblem('notBaseTitle', app)++ updates = sorted((int(v), os.path.join(updates_dir, v)) for v in versions)+ dlc: list[tuple[int, str]] = []+ dlc_dir = os.path.join(folder, 'dlc')+ for name in subdirs(dlc_dir):+ dpath = os.path.join(dlc_dir, name)+ if len(name) > 16:+ return GameFolderProblem('dlcName', name)+ try:+ tid = int(name, 16)+ except ValueError:+ return GameFolderProblem('dlcName', name)+ if not (tid > app + 0x1000 and tid - app - 0x1000 <= 2000):+ return GameFolderProblem('notDLC', name, tid)+ numbered = [sub for sub in subdirs(dpath) if os.path.isdir(os.path.join(dpath, sub, 'romfs'))]+ cnt = len(numbered) if numbered else (1 if os.path.isdir(os.path.join(dpath, 'romfs')) else 0)+ if cnt != 1:+ return GameFolderProblem('dlcRomFS', name, cnt)+ dlc.append((tid, dpath))++ dlc.sort(key=lambda x: x[0])+ return GameFolderContents(folder=folder, title_id=app, updates=updates, dlc=dlc)++ @staticmethod+ def profile_name(title_id: str | int, repo_path: str) -> str | None:+ if not repo_path:+ return None+ tid_hex = f'{title_id:016X}' if isinstance(title_id, int) else title_id.upper()+ tsv = os.path.join(repo_path, 'dm', 'games', tid_hex, 'game.tsv')+ if not os.path.isfile(tsv):+ return None+ try:+ with open(tsv, encoding='utf-8', errors='replace') as f:+ for line in f:+ if line.startswith('name\t'):+ val = line[5:].strip()+ return val if val else None+ except OSError:+ pass+ return None++ @staticmethod+ def profile_is_switch2(title_id: str, repo_path: str) -> bool:+ if not repo_path or len(title_id) != 16:+ return False+ tsv = os.path.join(repo_path, 'dm', 'games', title_id.upper(), 'game.tsv')+ if not os.path.isfile(tsv):+ return False+ try:+ with open(tsv, encoding='utf-8', errors='replace') as f:+ first = f.readline()+ return first.startswith('#') and '(Switch 2' in first+ except OSError:+ return False++ @staticmethod+ def engine_has_profile(title_id: int | str, repo_path: str) -> bool:+ if not repo_path:+ return False+ tid_hex = f'{title_id:016X}' if isinstance(title_id, int) else title_id.upper()+ return os.path.isfile(os.path.join(repo_path, 'dm', 'games', tid_hex, 'game.tsv'))++ @staticmethod+ def engine_builds_folders(repo_path: str) -> bool:+ return bool(repo_path and os.path.isfile(os.path.join(repo_path, 'scripts', 'pack_dump.py')))++ @staticmethod+ def engine_builds_nups(repo_path: str) -> bool:+ return bool(repo_path and os.path.isfile(os.path.join(repo_path, 'scripts', 'pack_nup.py')))+++# ---------------------------------------------------------------------------+# LibraryGame & GameLibrary (mirrors Library.swift)+# ---------------------------------------------------------------------------++@dataclass+class LibraryGame:+ title_id: str+ name: str+ app_path: str = ''+ ipa_path: str = ''+ archive_path: str = ''+ ios_app_path: str = ''+ output_dir: str = ''+ inputs: dict[str, list[str]] = field(default_factory=dict)+ added_at: float = field(default_factory=time.time)+ last_built_at: float | None = None+ built_chain_tag: str = ''++ @property+ def id(self) -> str:+ return self.title_id++ @property+ def has_app(self) -> bool:+ return bool(self.app_path and os.path.exists(self.app_path))++ @property+ def has_ipa(self) -> bool:+ return bool(self.ipa_path and os.path.isfile(self.ipa_path))++ @property+ def has_ios_app(self) -> bool:+ return bool(self.ios_app_path and os.path.exists(self.ios_app_path))++ @property+ def has_archive(self) -> bool:+ return bool(self.archive_path and os.path.isdir(self.archive_path))++ @property+ def has_any_build(self) -> bool:+ return self.has_app or self.has_ipa or self.has_ios_app or self.has_archive++ @property+ def has_inputs(self) -> bool:+ base = (self.inputs.get('base') or [''])[0]+ if not base or not os.path.exists(base):+ return False+ if GameFolder.is_candidate(base):+ return True+ keys = (self.inputs.get('keys') or [''])[0]+ return bool(keys and os.path.isfile(keys))++ @property+ def can_rebuild(self) -> bool:+ base = (self.inputs.get('base') or [''])[0]+ return bool(base and os.path.exists(base))++ @property+ def work_dir(self) -> str | None:+ out = self.output_dir+ if not out:+ base = (self.inputs.get('base') or [''])[0]+ if base:+ out = os.path.dirname(base)+ if not out:+ return None+ return os.path.join(out, f'{self.title_id}_build')++ def is_switch2(self, repo_path: str) -> bool:+ return GameFolder.profile_is_switch2(self.title_id, repo_path)++ def to_dict(self) -> dict:+ return {+ 'titleID': self.title_id,+ 'name': self.name,+ 'appPath': self.app_path,+ 'ipaPath': self.ipa_path,+ 'archivePath': self.archive_path,+ 'iosAppPath': self.ios_app_path,+ 'outputDir': self.output_dir,+ 'inputs': self.inputs,+ 'addedAt': self.added_at,+ 'lastBuiltAt': self.last_built_at,+ 'builtChainTag': self.built_chain_tag,+ }++ @classmethod+ def from_dict(cls, d: dict) -> LibraryGame:+ return cls(+ title_id=str(d.get('titleID') or d.get('title_id') or '').upper(),+ name=str(d.get('name') or ''),+ app_path=str(d.get('appPath') or ''),+ ipa_path=str(d.get('ipaPath') or ''),+ archive_path=str(d.get('archivePath') or ''),+ ios_app_path=str(d.get('iosAppPath') or ''),+ output_dir=str(d.get('outputDir') or ''),+ inputs=dict(d.get('inputs') or {}),+ added_at=float(d.get('addedAt') or time.time()),+ last_built_at=float(d['lastBuiltAt']) if d.get('lastBuiltAt') is not None else None,+ built_chain_tag=str(d.get('builtChainTag') or ''),+ )+++class GameLibrary:+ def __init__(self, state_dir: Path | None = None) -> None:+ self.state_dir = state_dir or default_state_dir()+ self.file_path = self.state_dir / 'library.json'+ self.games: list[LibraryGame] = []+ self.selected_id: str | None = None+ self.games_folder: str = ''+ self.load()++ @property+ def selected(self) -> LibraryGame | None:+ if self.selected_id:+ for g in self.games:+ if g.title_id == self.selected_id:+ return g+ return self.games[0] if self.games else None++ def select(self, title_id: str | None) -> None:+ self.selected_id = title_id.upper() if title_id else None++ def load(self) -> None:+ if not self.file_path.is_file():+ return+ try:+ raw = json.loads(self.file_path.read_text(encoding='utf-8'))+ if isinstance(raw, list):+ self.games = [LibraryGame.from_dict(x) for x in raw if isinstance(x, dict)]+ elif isinstance(raw, dict):+ self.games = [LibraryGame.from_dict(x) for x in raw.get('games', []) if isinstance(x, dict)]+ self.games_folder = str(raw.get('gamesFolder') or '')+ self.selected_id = raw.get('selectedID')+ if self.games and not self.selected_id:+ self.selected_id = self.games[0].title_id+ except Exception:+ pass++ def save(self) -> None:+ try:+ self.state_dir.mkdir(parents=True, exist_ok=True)+ payload = {+ 'gamesFolder': self.games_folder,+ 'selectedID': self.selected_id,+ 'games': [g.to_dict() for g in self.games],+ }+ self.file_path.write_text(json.dumps(payload, indent=2, ensure_ascii=False), encoding='utf-8')+ except OSError:+ pass++ def set_games_folder(self, folder: str, repo_path: str = '', default_keys: str = '') -> None:+ self.games_folder = folder+ if folder and os.path.isdir(folder):+ self.rescan_games_folder(repo_path=repo_path, default_keys=default_keys)+ self.save()++ def remove(self, title_id: str) -> None:+ tid = title_id.upper()+ self.games = [g for g in self.games if g.title_id != tid]+ if self.selected_id == tid:+ self.selected_id = self.games[0].title_id if self.games else None+ self.save()++ def upsert(self, game: LibraryGame) -> LibraryGame:+ tid = game.title_id.upper()+ game.title_id = tid+ for i, existing in enumerate(self.games):+ if existing.title_id == tid:+ if not game.name or game.name == tid:+ game.name = existing.name+ if not game.ipa_path:+ game.ipa_path = existing.ipa_path+ if not game.archive_path:+ game.archive_path = existing.archive_path+ if not game.output_dir:+ game.output_dir = existing.output_dir+ if not game.inputs:+ game.inputs = existing.inputs+ if game.last_built_at is None:+ game.last_built_at = existing.last_built_at+ self.games[i] = game+ self.save()+ return game+ self.games.insert(0, game)+ if not self.selected_id:+ self.selected_id = game.title_id+ self.save()+ return game++ def remember_inputs(+ self,+ base_path: str,+ update_path: str,+ dlc_paths: list[str],+ keys_path: str,+ output_dir: str,+ repo_path: str = '',+ ) -> LibraryGame | None:+ if not base_path:+ return None+ tid = ''+ name = ''+ if GameFolder.is_candidate(base_path):+ res = GameFolder.scan(base_path if not os.path.basename(base_path) == 'base' else os.path.dirname(base_path))+ if isinstance(res, GameFolderContents) and res.has_title_id:+ tid = res.title_id_hex+ name = GameFolder.profile_name(tid, repo_path) or clean_game_name(res.folder)+ if not tid:+ tid_raw = extract_title_id(base_path)+ if tid_raw:+ tid = base_family_id(tid_raw)+ if not tid:+ return None+ if not name:+ name = GameFolder.profile_name(tid, repo_path) or clean_game_name(base_path)++ inputs: dict[str, list[str]] = {'base': [base_path]}+ if update_path:+ inputs['update'] = [update_path]+ if dlc_paths:+ inputs['dlc'] = list(dlc_paths)+ if keys_path:+ inputs['keys'] = [keys_path]++ out = output_dir or os.path.dirname(base_path)+ ipa_candidate = os.path.join(out, f'{name}.ipa')+ archive_candidate = os.path.join(out, 'games', tid)+ game = LibraryGame(+ title_id=tid,+ name=name,+ ipa_path=ipa_candidate if os.path.isfile(ipa_candidate) else '',+ archive_path=archive_candidate if os.path.isdir(archive_candidate) else '',+ output_dir=output_dir,+ inputs=inputs,+ )+ g = self.upsert(game)+ self.selected_id = g.title_id+ self.save()+ return g++ def record_completed_ios(+ self,+ ipa_path: str,+ archive_path: str,+ base_path: str,+ output_dir: str,+ inputs: dict[str, list[str]],+ repo_path: str = '',+ ) -> LibraryGame | None:+ tid = ''+ if archive_path:+ bn = os.path.basename(archive_path.rstrip('/\\'))+ if len(bn) == 16:+ tid = bn.upper()+ if not tid and base_path:+ if GameFolder.is_candidate(base_path):+ res = GameFolder.scan(base_path if os.path.basename(base_path) != 'base' else os.path.dirname(base_path))+ if isinstance(res, GameFolderContents) and res.has_title_id:+ tid = res.title_id_hex+ if not tid:+ tid_raw = extract_title_id(base_path)+ if tid_raw:+ tid = base_family_id(tid_raw)+ if not tid and ipa_path:+ tid_raw = extract_title_id(ipa_path)+ if tid_raw:+ tid = base_family_id(tid_raw)+ if not tid:+ tid = '0100000000000000'++ name = GameFolder.profile_name(tid, repo_path)+ if not name:+ if ipa_path:+ name = clean_game_name(ipa_path)+ elif base_path:+ name = clean_game_name(base_path)+ else:+ name = tid++ game = LibraryGame(+ title_id=tid,+ name=name,+ ipa_path=ipa_path if (ipa_path and os.path.isfile(ipa_path)) else '',+ archive_path=archive_path if (archive_path and os.path.isdir(archive_path)) else '',+ output_dir=output_dir,+ inputs=inputs,+ last_built_at=time.time(),+ )+ g = self.upsert(game)+ self.selected_id = g.title_id+ self.save()+ return g++ def rescan_games_folder(self, repo_path: str = '', default_keys: str = '') -> int:+ folder = self.games_folder+ if not folder or not os.path.isdir(folder):+ return 0+ discovered = self.discover_in_folder(folder, repo_path=repo_path, default_keys=default_keys)+ count = 0+ for g in discovered:+ self.upsert(g)+ count += 1+ self.save()+ return count++ @staticmethod+ def discover_in_folder(folder: str, repo_path: str = '', default_keys: str = '') -> list[LibraryGame]:+ if not folder or not os.path.isdir(folder):+ return []+ families: dict[str, dict[str, list[str]]] = {}+ names: dict[str, str] = {}+ ipas: dict[str, str] = {}+ archives: dict[str, str] = {}+ found_keys = default_keys if (default_keys and os.path.isfile(default_keys)) else ''++ def walk_dir(curr: str, depth: int) -> None:+ nonlocal found_keys+ if depth > 3:+ return+ if GameFolder.is_candidate(curr):+ res = GameFolder.scan(curr)+ if isinstance(res, GameFolderContents) and res.has_title_id:+ tid = res.title_id_hex+ families.setdefault(tid, {})['base'] = [res.script_input]+ if res.newest_update:+ families[tid]['update'] = [res.newest_update[1]]+ if res.dlc:+ families[tid]['dlc'] = [p for _, p in res.dlc]+ names[tid] = GameFolder.profile_name(tid, repo_path) or clean_game_name(curr)+ return++ try:+ entries = sorted(os.listdir(curr))+ except OSError:+ return++ for entry in entries:+ if entry.startswith('.'):+ continue+ full = os.path.join(curr, entry)+ low = entry.lower()+ if os.path.isfile(full):+ if low in ('prod.keys', 'keys.txt') or low.endswith('.keys'):+ if not found_keys:+ found_keys = full+ continue+ ext = os.path.splitext(low)[1]+ if ext == '.nup':+ res = GameFolder.read_nup(full)+ if isinstance(res, GameFolderContents) and res.has_title_id:+ tid = res.title_id_hex+ families.setdefault(tid, {})['base'] = [full]+ names[tid] = GameFolder.profile_name(tid, repo_path) or clean_game_name(full)+ elif ext in PACKAGE_EXTS:+ tid_raw = extract_title_id(entry)+ if tid_raw:+ fam = base_family_id(tid_raw)+ kind = classify_tid(tid_raw)+ slot = families.setdefault(fam, {})+ if kind == 'base':+ slot['base'] = [full]+ names[fam] = GameFolder.profile_name(fam, repo_path) or clean_game_name(entry)+ elif kind == 'update':+ slot.setdefault('update', []).append(full)+ else:+ slot.setdefault('dlc', []).append(full)+ elif ext == '.ipa':+ tid_raw = extract_title_id(entry)+ if tid_raw:+ ipas[base_family_id(tid_raw)] = full+ elif os.path.isdir(full):+ if entry.endswith('_build'):+ continue+ if entry == 'games':+ try:+ for sub in os.listdir(full):+ sub_full = os.path.join(full, sub)+ if len(sub) == 16 and os.path.isdir(sub_full):+ archives[sub.upper()] = sub_full+ except OSError:+ pass+ continue+ walk_dir(full, depth + 1)++ walk_dir(folder, 0)+ results: list[LibraryGame] = []+ for tid, slots in families.items():+ if 'base' not in slots:+ continue+ if found_keys and 'keys' not in slots:+ slots['keys'] = [found_keys]+ if 'update' in slots and len(slots['update']) > 1:+ slots['update'] = [sorted(slots['update'])[-1]]+ gname = names.get(tid) or GameFolder.profile_name(tid, repo_path) or tid+ base_dir = os.path.dirname(slots['base'][0])++ other_files = slots.get('update', []) + slots.get('dlc', [])++ if other_files and any(not os.path.abspath(p).startswith(os.path.abspath(base_dir) + os.sep) for p in other_files):++ parent_dir = os.path.dirname(base_dir)++ if parent_dir and os.path.abspath(parent_dir).startswith(os.path.abspath(folder)):++ base_dir = parent_dir+ ipa = ipas.get(tid, '')+ if not ipa:+ cand = os.path.join(base_dir, f'{gname}.ipa')+ if os.path.isfile(cand):+ ipa = cand+ arch = archives.get(tid, '')+ if not arch:+ cand_arch = os.path.join(base_dir, 'games', tid)+ if os.path.isdir(cand_arch):+ arch = cand_arch+ results.append(+ LibraryGame(+ title_id=tid,+ name=gname,+ ipa_path=ipa,+ archive_path=arch,+ output_dir=base_dir,+ inputs=slots,+ )+ )+ return results+++# ---------------------------------------------------------------------------+# ArtworkStore & eShop Banner fetcher (mirrors Artwork.swift & BannerPick.swift)+# ---------------------------------------------------------------------------++class ArtworkStore:+ TITLEDB_URL = 'https://raw.githubusercontent.com/blawar/titledb/master/US.en.json'++ def __init__(self, state_dir: Path | None = None, on_updated: Callable[[str], None] | None = None) -> None:+ self.state_dir = state_dir or default_state_dir()+ self.banners_dir = self.state_dir / 'banners'+ self.custom_file = self.state_dir / 'custom_artwork.json'+ self.on_updated = on_updated+ self.custom_paths: dict[str, str] = {}+ self._fetching: set[str] = set()+ self._titledb_cache: dict[str, str] | None = None+ self._lock = threading.Lock()+ self._load_custom()++ def _load_custom(self) -> None:+ if self.custom_file.is_file():+ try:+ data = json.loads(self.custom_file.read_text(encoding='utf-8'))+ if isinstance(data, dict):+ self.custom_paths = {k.upper(): str(v) for k, v in data.items() if v}+ except Exception:+ pass++ def _save_custom(self) -> None:+ try:+ self.state_dir.mkdir(parents=True, exist_ok=True)+ self.custom_file.write_text(json.dumps(self.custom_paths, indent=2), encoding='utf-8')+ except OSError:+ pass++ def set_custom(self, title_id: str, image_path: str) -> None:+ tid = title_id.upper()+ self.custom_paths[tid] = image_path+ self._save_custom()+ if self.on_updated:+ self.on_updated(tid)++ def clear_custom(self, title_id: str) -> None:+ tid = title_id.upper()+ self.custom_paths.pop(tid, None)+ self._save_custom()+ if self.on_updated:+ self.on_updated(tid)++ def has_custom(self, title_id: str) -> bool:+ tid = title_id.upper()+ p = self.custom_paths.get(tid, '')+ return bool(p and os.path.isfile(p))++ def image_path(self, title_id: str, repo_path: str = '') -> str | None:+ tid = title_id.upper()+ custom = self.custom_paths.get(tid, '')+ if custom and os.path.isfile(custom):+ return custom+ cached = self.banners_dir / f'{tid}.jpg'+ if cached.is_file():+ return str(cached)+ cached_png = self.banners_dir / f'{tid}.png'+ if cached_png.is_file():+ return str(cached_png)+ if repo_path:+ gal = self._gallery_map(repo_path)+ if tid in gal:+ p = os.path.join(repo_path, 'docs', 'images', gal[tid])+ if os.path.isfile(p):+ return p+ if tid in BUNDLED_ART:+ bundled = os.path.join(repo_path, BUNDLED_ART[tid])+ if os.path.isfile(bundled):+ return bundled+ return None++ def _gallery_map(self, repo_path: str) -> dict[str, str]:+ cache: dict[str, dict[str, str]] = getattr(self, '_gal_cache', {})+ if repo_path in cache:+ return cache[repo_path]+ out: dict[str, str] = {}+ tsv = os.path.join(repo_path, 'docs', 'images', 'gallery.tsv')+ if os.path.isfile(tsv):+ try:+ with open(tsv, encoding='utf-8', errors='replace') as f:+ for line in f:+ if not line or line.startswith('#'):+ continue+ parts = line.rstrip('\r\n').split('\t')+ if len(parts) >= 4 and len(parts[3]) == 16:+ out[parts[3].upper()] = parts[0]+ except OSError:+ pass+ cache[repo_path] = out+ self._gal_cache = cache+ return out++ def request_banner_async(self, title_id: str) -> None:+ if os.environ.get('QT_QPA_PLATFORM') == 'offscreen':+ return+ tid = title_id.upper()+ if self.has_custom(tid) or (self.banners_dir / f'{tid}.jpg').is_file():+ return+ with self._lock:+ if tid in self._fetching:+ return+ self._fetching.add(tid)++ def worker() -> None:+ try:+ self._fetch_one(tid)+ finally:+ with self._lock:+ self._fetching.discard(tid)++ threading.Thread(target=worker, daemon=True).start()++ def _fetch_one(self, tid: str) -> None:+ index_file = self.banners_dir / 'banners_index.json'+ mapping: dict[str, str] = {}+ if index_file.is_file():+ try:+ mapping = json.loads(index_file.read_text(encoding='utf-8'))+ except Exception:+ mapping = {}++ url = mapping.get(tid)+ if not url and not mapping:+ try:+ req = urllib.request.Request(self.TITLEDB_URL, headers={'User-Agent': 'NX2Apple/1.1'})+ with urllib.request.urlopen(req, timeout=15) as resp:+ raw = json.loads(resp.read().decode('utf-8', errors='replace'))+ if isinstance(raw, dict):+ for entry in raw.values():+ if isinstance(entry, dict):+ etid = str(entry.get('id') or '').upper()+ burl = str(entry.get('bannerUrl') or '')+ if len(etid) == 16 and burl.startswith('http'):+ mapping[etid] = burl+ self.banners_dir.mkdir(parents=True, exist_ok=True)+ index_file.write_text(json.dumps(mapping), encoding='utf-8')+ url = mapping.get(tid)+ except Exception:+ return++ if not url:+ return+ try:+ req = urllib.request.Request(url, headers={'User-Agent': 'NX2Apple/1.1'})+ with urllib.request.urlopen(req, timeout=15) as resp:+ data = resp.read()+ if len(data) > 1024:+ self.banners_dir.mkdir(parents=True, exist_ok=True)+ dest = self.banners_dir / f'{tid}.jpg'+ dest.write_bytes(data)+ if self.on_updated:+ self.on_updated(tid)+ except Exception:+ pass+++# ---------------------------------------------------------------------------+# BuildFolder Space Measurement & Cleanup (mirrors FreeSpace.swift)+# ---------------------------------------------------------------------------++@dataclass+class BuildFolderItem:+ part: str # 'extracted', 'shaders', 'oldShaders', 'xcode', 'caches'+ bytes: int+ paths: list[str]+++@dataclass+class BuildFolderReport:+ folder: str+ items: list[BuildFolderItem]+ kept_bytes: int++ @property+ def total_freeable(self) -> int:+ # oldShaders is a subset of shaders+ return sum(i.bytes for i in self.items if i.part != 'oldShaders')+++class BuildFolder:+ PART_ORDER = ['extracted', 'shaders', 'oldShaders', 'xcode', 'caches']++ @staticmethod+ def size(path: str) -> int:+ if not path or not os.path.exists(path):+ return 0+ if os.path.isfile(path) or os.path.islink(path):+ try:+ return os.path.getsize(path)+ except OSError:+ return 0+ total = 0+ for root, _, files in os.walk(path):+ for f in files:+ fp = os.path.join(root, f)+ try:+ if not os.path.islink(fp):+ total += os.path.getsize(fp)+ except OSError:+ pass+ return total++ @staticmethod+ def location(game: LibraryGame) -> str | None:+ w = game.work_dir+ if w and os.path.isdir(w):+ return w+ return None++ @staticmethod+ def inspect(folder: str, title_id: str) -> BuildFolderReport:+ if not folder or not os.path.isdir(folder):+ return BuildFolderReport(folder=folder or '', items=[], kept_bytes=0)++ tid = title_id.upper()+ extracted_paths: list[str] = []+ shader_paths: list[str] = []+ old_shader_paths: list[str] = []+ xcode_paths: list[str] = []+ cache_paths: list[str] = []+ kept_paths: list[str] = []++ tid_dir = os.path.join(folder, tid)+ if os.path.isdir(tid_dir):+ extracted_paths.append(tid_dir)++ for sub in ('shaders', 'shader_cache', 'ios_shaders', 'mac_shaders'):+ p = os.path.join(folder, sub)+ if os.path.exists(p):+ shader_paths.append(p)+ # Look for older shader chain directories inside+ if os.path.isdir(p):+ try:+ chains = [+ os.path.join(p, d)+ for d in os.listdir(p)+ if d.startswith('b-') and os.path.isdir(os.path.join(p, d))+ ]+ if len(chains) > 1:+ chains.sort(key=lambda x: os.path.getmtime(x))+ old_shader_paths.extend(chains[:-1])+ except OSError:+ pass++ for sub in ('ios_xcode', 'xcode', 'app_build', 'build'):+ p = os.path.join(folder, sub)+ if os.path.exists(p):+ xcode_paths.append(p)++ known = {tid, 'shaders', 'shader_cache', 'ios_shaders', 'mac_shaders', 'ios_xcode', 'xcode', 'app_build', 'build'}+ kept_names = {'run', 'saves', 'build.log', 'game.tsv'}+ try:+ for name in os.listdir(folder):+ if name in known:+ continue+ full = os.path.join(folder, name)+ if name in kept_names or name.endswith('.log') or name.endswith('.tsv') or name.endswith('.nsp'):+ kept_paths.append(full)+ else:+ cache_paths.append(full)+ except OSError:+ pass++ items: list[BuildFolderItem] = []+ for part, plist in (+ ('extracted', extracted_paths),+ ('shaders', shader_paths),+ ('oldShaders', old_shader_paths),+ ('xcode', xcode_paths),+ ('caches', cache_paths),+ ):+ b = sum(BuildFolder.size(p) for p in plist)+ if b > 0:+ items.append(BuildFolderItem(part=part, bytes=b, paths=plist))++ kept_bytes = sum(BuildFolder.size(p) for p in kept_paths)+ return BuildFolderReport(folder=folder, items=items, kept_bytes=kept_bytes)++ @staticmethod+ def remove(report: BuildFolderReport, selected_parts: set[str]) -> tuple[int, list[str]]:+ parts = set(selected_parts)+ if 'shaders' in parts:+ parts.discard('oldShaders')+ freed = 0+ failed: list[str] = []+ for item in report.items:+ if item.part not in parts:+ continue+ for p in item.paths:+ if not os.path.exists(p):+ continue+ sz = BuildFolder.size(p)+ try:+ if os.path.isdir(p) and not os.path.islink(p):+ shutil.rmtree(p)+ else:+ os.remove(p)+ freed += sz+ except OSError:+ failed.append(p)+ return freed, failed+++# ---------------------------------------------------------------------------+# GameDeletion (mirrors GameDeletion.swift)+# ---------------------------------------------------------------------------++@dataclass+class GameDeletionItem:+ kind: str # 'macApp', 'ipa', 'iosApp', 'archive', 'shellFramework', 'buildFolder', 'log', 'saves'+ paths: list[str]+ bytes: int = 0+++@dataclass+class GameDeletionPlan:+ title_id: str+ items: list[GameDeletionItem]+ saves: GameDeletionItem | None = None++ @staticmethod+ def plan(game: LibraryGame, measure: bool = True) -> GameDeletionPlan:+ items: list[GameDeletionItem] = []+ if game.has_app:+ items.append(GameDeletionItem('macApp', [game.app_path]))+ if game.has_ipa:+ items.append(GameDeletionItem('ipa', [game.ipa_path]))+ if game.has_archive and os.path.basename(game.archive_path.rstrip('/\\')).upper() == game.title_id.upper():+ items.append(GameDeletionItem('archive', [game.archive_path]))++ bf = BuildFolder.location(game)+ if bf:+ try:+ sub_paths = [+ os.path.join(bf, name)+ for name in sorted(os.listdir(bf))+ if name != 'run'+ ]+ except OSError:+ sub_paths = []+ if sub_paths:+ items.append(GameDeletionItem('buildFolder', sub_paths))++ saves_paths: list[str] = []+ if bf and os.path.exists(os.path.join(bf, 'run')):+ saves_paths.append(os.path.join(bf, 'run'))++ saves_item = GameDeletionItem('saves', saves_paths) if saves_paths else None+ if measure:+ for it in items:+ it.bytes = sum(BuildFolder.size(p) for p in it.paths)+ if saves_item:+ saves_item.bytes = sum(BuildFolder.size(p) for p in saves_item.paths)++ return GameDeletionPlan(title_id=game.title_id, items=items, saves=saves_item)++ def run(self, delete_saves: bool = False) -> list[str]:+ failed: list[str] = []+ all_items = list(self.items)+ if delete_saves and self.saves:+ all_items.append(self.saves)+ for it in all_items:+ for p in it.paths:+ if not os.path.exists(p):+ continue+ try:+ if os.path.isdir(p) and not os.path.islink(p):+ shutil.rmtree(p)+ else:+ os.remove(p)+ except OSError:+ failed.append(p)+ return failed+++# ---------------------------------------------------------------------------+# DriveCopy (mirrors DriveCopy.swift)+# ---------------------------------------------------------------------------++class DriveCopy:+ FAT32_LIMIT = 4_294_967_295++ @staticmethod+ def collect_archive_files(archive_dir: str) -> dict[str, int]:+ out: dict[str, int] = {}+ if not archive_dir or not os.path.isdir(archive_dir):+ return out+ for root, _, files in os.walk(archive_dir):+ for f in files:+ if f.startswith('.'):+ continue+ full = os.path.join(root, f)+ rel = os.path.relpath(full, archive_dir).replace('\\', '/')+ try:+ out[rel] = os.path.getsize(full)+ except OSError:+ pass+ return out++ @staticmethod+ def free_space(folder: str) -> int:+ probe = folder+ while probe and not os.path.exists(probe):+ parent = os.path.dirname(probe)+ if parent == probe:+ break+ probe = parent+ try:+ return shutil.disk_usage(probe or '.').free+ except OSError:+ return 0++ @staticmethod+ def copy_to_folder(+ archive_dir: str,+ dest_root: str,+ title_id: str,+ progress_cb: Callable[[int, int], None] | None = None,+ ) -> tuple[bool, str]:+ files = DriveCopy.collect_archive_files(archive_dir)+ if not files:+ return False, 'No game data files found'+ dest_dir = os.path.join(dest_root, title_id.upper())+ total = sum(files.values())+ free = DriveCopy.free_space(dest_root)+ if free > 0 and total > free:+ return False, f'Not enough space ({format_bytes(total)} needed, {format_bytes(free)} free)'+ done = 0+ if progress_cb:+ progress_cb(0, total)+ try:+ for rel, sz in sorted(files.items()):+ src = os.path.join(archive_dir, rel)+ dst = os.path.join(dest_dir, rel)+ os.makedirs(os.path.dirname(dst), exist_ok=True)+ if os.path.isfile(dst) and os.path.getsize(dst) == sz:+ done += sz+ if progress_cb:+ progress_cb(done, total)+ continue+ partial = dst + '.partial'+ with open(src, 'rb') as fin, open(partial, 'wb') as fout:+ while True:+ buf = fin.read(4 * 1024 * 1024)+ if not buf:+ break+ fout.write(buf)+ done += len(buf)+ if progress_cb:+ progress_cb(done, total)+ if os.path.exists(dst):+ os.remove(dst)+ os.replace(partial, dst)+ return True, dest_dir+ except OSError as e:+ return False, str(e)diff --cc frontend-qt/nspb_qt/ui.pyindex 1816ae2f,190546fd..b8522569--- a/frontend-qt/nspb_qt/ui.py+++ b/frontend-qt/nspb_qt/ui.py@@@ -1,130 -1,24 +1,131 @@@-"""The window: header, repository, inputs, dependencies, build progress, log.--The layout follows the SwiftUI app section for section, so a user who has seen one recognises-the other: rounded cards on a dark background, a coloured dot per row, monospaced paths.-"""+"""Main window mirroring the Mac SwiftUI launcher (Library / Builds / Settings + Hero + Sheets)."""from __future__ import annotations+import osfrom pathlib import Path-from PySide6.QtCore import Qt, QUrl-from PySide6.QtGui import QDesktopServices, QFontDatabase+from PySide6.QtCore import QPoint, QTimer, QUrl, Qt+from PySide6.QtGui import QDesktopServices, QDragEnterEvent, QDropEvent, QFont, QIcon, QMouseEvent, QPixmapfrom PySide6.QtWidgets import (- QFileDialog, QFrame, QGridLayout, QHBoxLayout, QLabel, QMainWindow,- QProgressBar, QPushButton, QScrollArea, QSizePolicy, QTextEdit, QVBoxLayout, QWidget,+ QApplication,+ QComboBox,+ QFileDialog,+ QFrame,+ QHBoxLayout,+ QLabel,+ QLineEdit,+ QMainWindow,+ QMenu,+ QMessageBox,+ QPlainTextEdit,+ QProgressBar,+ QPushButton,+ QScrollArea,+ QSizePolicy,+ QStackedWidget,+ QVBoxLayout,+ QWidget,)+from . import build_failure as bf+from . import features as featfrom . import inputs+from . import library as libfrom . import platform_util as pu+from . import style+ from .build_notes import TEXT, TITLE, stale_reason-from .model import DepState, Model-from .style import CARD_EDGE, GREEN, MUTED, ORANGE, RED+- APP_VERSION = '1.1.0'++APP_VERSION = '1.1.1'+from .i18n import Lang+from .model import Dep, DepState, Model+from .sheets import CheatsDialog, DeleteGameDialog, FreeSpaceDialog, OnboardingDialog+from .widgets import (+ CardGroup,+ CardPageHeading,+ DropOverlayWidget,+ GameCardWidget,+ HeroBannerWidget,+ LauncherSegmented,+ LauncherSwitch,+ StatusDot,+ make_divider,+)+++def _dot(color: str) -> QLabel:+ d = QLabel()+ d.setFixedSize(8, 8)+ d.setStyleSheet(f'background: {color}; border-radius: 4px;')+ return d+++def _set_dot(d: QLabel, color: str) -> None:+ d.setStyleSheet(f'background: {color}; border-radius: 4px;')+++class TopBarFrame(QFrame):+ """Custom frameless top bar that keeps the center navigation tabs pinned at the exact horizontal center+ and supports dragging / double-clicking to move or maximize the window."""++ def __init__(self, parent: QWidget | None = None) -> None:+ super().__init__(parent)+ self.nav_container: QWidget | None = None+ self.search_box: QLineEdit | None = None+ self._drag_offset: QPoint | None = None++ def recenter_nav(self) -> None:+ if self.search_box is not None:+ sw = max(108, min(172, self.width() - 845))+ self.search_box.setFixedWidth(sw)+ if self.nav_container is None:+ return+ self.nav_container.adjustSize()+ nw = self.nav_container.width()+ nh = self.nav_container.height()+ x = max(0, (self.width() - nw) // 2)+ y = max(0, (self.height() - nh) // 2)+ self.nav_container.setGeometry(x, y, nw, nh)+ self.nav_container.raise_()++ def resizeEvent(self, event) -> None:+ super().resizeEvent(event)+ self.recenter_nav()++ def mousePressEvent(self, event: QMouseEvent) -> None:+ if event.button() == Qt.LeftButton:+ win = self.window()+ wh = win.windowHandle() if win else None+ if wh is not None and hasattr(wh, 'startSystemMove'):+ if wh.startSystemMove():+ event.accept()+ return+ if win is not None and not win.isMaximized():+ self._drag_offset = event.globalPosition().toPoint() - win.frameGeometry().topLeft()+ event.accept()+ return+ super().mousePressEvent(event)++ def mouseMoveEvent(self, event: QMouseEvent) -> None:+ if self._drag_offset is not None and (event.buttons() & Qt.LeftButton):+ win = self.window()+ if win is not None and not win.isMaximized():+ win.move(event.globalPosition().toPoint() - self._drag_offset)+ event.accept()+ return+ super().mouseMoveEvent(event)++ def mouseReleaseEvent(self, event: QMouseEvent) -> None:+ self._drag_offset = None+ super().mouseReleaseEvent(event)++ def mouseDoubleClickEvent(self, event: QMouseEvent) -> None:+ if event.button() == Qt.LeftButton:+ win = self.window()+ if hasattr(win, '_toggle_maximize_window'):+ win._toggle_maximize_window()+ event.accept()+ return+ super().mouseDoubleClickEvent(event)class MainWindow(QMainWindow):@@@ -207,2255 -74,747 +208,2262 @@@self.m.depsChanged.connect(self._refresh_deps)self.m.repoChanged.connect(self._refresh_all)self.m.stagesChanged.connect(self._refresh_stages)- self.m.logAppended.connect(self._append_log)self.m.runningChanged.connect(self._refresh_running)+ self.m.logAppended.connect(self._append_log)self.m.finished.connect(self._on_finished)+ self.m.appUpdateFound.connect(self._on_app_update)+ self.m.libraryChanged.connect(self._refresh_library)++ if self.m.log_path:+ self._append_log(self.m.t('log.at', str(self.m.log_path)) + '\n\n')++ self._switch_page('builds')self._refresh_all()- self.m.ask_folder = lambda title: self._ask_folder(title)- self.m.ask_file = lambda title: self._ask_file(title)- self.m.check_deps()+ for g in self.m.library.games:+ self.m.artwork.request_banner_async(g.title_id)- # ---------------------------------------------------------------- header+ self._init_timer = QTimer(self)+ self._init_timer.setSingleShot(True)+ self._init_timer.timeout.connect(self.m.check_deps)+ self._init_timer.start(50)++ # ================================================================ Top Bar & Window Controls++ def _toggle_maximize_window(self) -> None:+ if self.isMaximized():+ self.showNormal()+ self.max_win_btn.setText('□')+ else:+ self.showMaximized()+ self.max_win_btn.setText('❐')++ def _build_top_bar(self) -> TopBarFrame:+ bar = TopBarFrame()+ bar.setObjectName('topBar')+ bar.setFixedHeight(64)+ row = QHBoxLayout(bar)+ row.setContentsMargins(24, 0, 16, 0)+ row.setSpacing(10)++ # Brand (App Icon + NX2Apple — by nxnative)+ brand_row = QHBoxLayout()+ brand_row.setSpacing(10)+ self.app_icon_lbl = QLabel()+ self.app_icon_lbl.setFixedSize(26, 26)+ icon_file = Path(__file__).resolve().parent / 'assets' / 'app_icon.png'+ if icon_file.is_file():+ pm = QPixmap(str(icon_file))+ if not pm.isNull():+ self.app_icon_lbl.setPixmap(+ pm.scaled(26, 26, Qt.KeepAspectRatio, Qt.SmoothTransformation)+ )+ brand_row.addWidget(self.app_icon_lbl)+ self.title_label = QLabel('NX2Apple')+ self.title_label.setStyleSheet('font-size: 23px; font-weight: 800; color: #ffffff;')+ self.sub_label = QLabel('— by nxnative')+ self.sub_label.setObjectName('faint')+ brand_row.addWidget(self.title_label)+ brand_row.addWidget(self.sub_label)+ row.addLayout(brand_row)- def _build_header(self) -> None:- row = QHBoxLayout()- row.setSpacing(8)row.addStretch(1)++ # Pinned-center Navigation tabs: Library / Builds / Settings+ nav_host = QWidget(bar)+ nav_wrap = QHBoxLayout(nav_host)+ nav_wrap.setContentsMargins(0, 0, 0, 0)+ nav_wrap.setSpacing(4)+ self.nav_btns: dict[str, QPushButton] = {}+ for page_id in ('library', 'builds', 'settings'):+ btn = QPushButton(self.m.t('nav.' + page_id))+ btn.setCursor(Qt.PointingHandCursor)+ btn.clicked.connect(lambda _=False, p=page_id: self._switch_page(p))+ self.nav_btns[page_id] = btn+ nav_wrap.addWidget(btn)+ bar.nav_container = nav_host+ bar.recenter_nav()++ # Trailing controls: Search input + New Build + Update pill + Window controls (Min/Max/Close)+ self.search_input = QLineEdit()+ self.search_input.setObjectName('searchField')+ self.search_input.setPlaceholderText(self.m.t('library.search'))+ self.search_input.setFixedWidth(172)+ self.search_input.setClearButtonEnabled(True)+ self.search_input.textChanged.connect(self._on_search_changed)+ bar.search_box = self.search_input+ row.addWidget(self.search_input)++ self.new_build_btn = QPushButton('+ ' + self.m.t('library.newBuild'))+ self.new_build_btn.setCursor(Qt.PointingHandCursor)+ self.new_build_btn.clicked.connect(lambda: self._switch_page('builds'))+ row.addWidget(self.new_build_btn)++ self.update_btn = QPushButton('')+ self.update_btn.setObjectName('creamPill')+ self.update_btn.hide()+ row.addWidget(self.update_btn)+self.lang_btn = QPushButton(self.m.lang.toggle_label)- self.lang_btn.clicked.connect(self._toggle_lang)- row.addWidget(self.lang_btn, 0, Qt.AlignTop)- self.body.addLayout(row)+ self.lang_btn.setFixedWidth(92)+ self.lang_btn.clicked.connect(self.m.toggle_lang)+ self.lang_btn.hide() # Language selection lives in Settings -> App -> Language, matching the Mac SwiftUI top bar++ # Built-in Frameless Window Controls (Minimize / Maximize / Close)+ win_ctrl_wrap = QHBoxLayout()+ win_ctrl_wrap.setContentsMargins(6, 0, 0, 0)+ win_ctrl_wrap.setSpacing(2)++ self.min_win_btn = QPushButton('—')+ self.min_win_btn.setObjectName('winCtrlBtn')+ self.min_win_btn.setFixedSize(36, 28)+ self.min_win_btn.setCursor(Qt.PointingHandCursor)+ self.min_win_btn.clicked.connect(self.showMinimized)+ win_ctrl_wrap.addWidget(self.min_win_btn)++ self.max_win_btn = QPushButton('□')+ self.max_win_btn.setObjectName('winCtrlBtn')+ self.max_win_btn.setFixedSize(36, 28)+ self.max_win_btn.setCursor(Qt.PointingHandCursor)+ self.max_win_btn.clicked.connect(self._toggle_maximize_window)+ win_ctrl_wrap.addWidget(self.max_win_btn)++ self.close_win_btn = QPushButton('✕')+ self.close_win_btn.setObjectName('winCloseBtn')+ self.close_win_btn.setFixedSize(36, 28)+ self.close_win_btn.setCursor(Qt.PointingHandCursor)+ self.close_win_btn.clicked.connect(self.close)+ win_ctrl_wrap.addWidget(self.close_win_btn)++ row.addLayout(win_ctrl_wrap)- # ---------------------------------------------------------------- cards+ return bar- def _card(self, title_key: str, note_key: str = '') -> tuple[QFrame, QVBoxLayout]:- # title/note are registered for re-translation: the language toggle rebuilds nothing, it- # re-sets text — and a card title built once at start-up stayed English after the toggle- # (the report's half-Chinese interface).+ def _switch_page(self, page_id: str) -> None:+ self._current_page = page_id+ self.library_page.setVisible(page_id == 'library')+ self.builds_page.setVisible(page_id == 'builds')+ self.settings_page.setVisible(page_id == 'settings')+ self.stack.setCurrentIndex(0)+ self.scroll.verticalScrollBar().setValue(0)+ for pid, btn in self.nav_btns.items():+ btn.setObjectName('navTabActive' if pid == page_id else 'navTab')+ btn.style().unpolish(btn)+ btn.style().polish(btn)+ self.search_input.setVisible(page_id == 'library')+ self.new_build_btn.setVisible(page_id != 'builds')+ self.top_bar.recenter_nav()+ if page_id == 'library':+ self._refresh_library()++ # ================================================================ Engine Banner++ def _build_engine_banner(self) -> QFrame:box = QFrame()- box.setObjectName('card')- lay = QVBoxLayout(box)- lay.setContentsMargins(12, 10, 12, 10)- lay.setSpacing(6)- head = QHBoxLayout()- head.setSpacing(6)- t = QLabel(self.m.t(title_key))- t.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)- f = t.font()- f.setBold(True)- f.setPointSize(13)- t.setFont(f)- head.addWidget(t)- n = None- if note_key:- n = QLabel(self.m.t(note_key))- n.setObjectName('note')- head.addWidget(n)- head.addStretch(1)- lay.addLayout(head)- self._translatable.append((t, title_key))- if n is not None:- self._translatable.append((n, note_key))- self.body.addWidget(box)- return box, lay-- def _build_repository(self) -> None:- box, lay = self._card('repo.title', 'repo.note')- self.repo_box = box+ box.setObjectName('bannerCard')+ box.setContentsMargins(28, 8, 28, 0)+ col = QVBoxLayout(box)+ col.setContentsMargins(16, 12, 16, 12)+ col.setSpacing(6)+ self.engine_sync_label = QLabel()+ self.engine_sync_label.setWordWrap(True)+ col.addWidget(self.engine_sync_label)+ self.engine_fail_what = QLabel()+ self.engine_fail_what.setStyleSheet('font-weight: 700;')+ self.engine_fail_what.setWordWrap(True)+ col.addWidget(self.engine_fail_what)+ self.engine_fail_next = QLabel()+ self.engine_fail_next.setObjectName('muted')+ self.engine_fail_next.setWordWrap(True)+ col.addWidget(self.engine_fail_next)row = QHBoxLayout()- self.repo_dot = QLabel('●')- self.repo_dot.setFixedWidth(14)- row.addWidget(self.repo_dot)- self.repo_path_label = QLabel('')- self.repo_path_label.setObjectName('mono')- self.repo_path_label.setTextInteractionFlags(Qt.TextSelectableByMouse)- self.repo_path_label.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Preferred) # long paths shrink, the buttons stay on screen- self.repo_path_label.setMinimumWidth(60)- row.addWidget(self.repo_path_label, 1)- self.choose_btn = QPushButton(self.m.t('repo.choose'))- self._translatable.append((self.choose_btn, 'repo.choose'))- self.choose_btn.clicked.connect(self._choose_repo)- row.addWidget(self.choose_btn)- lay.addLayout(row)- # A machine without a clone gets Download; a clone gets one update button (fetch, then- # fast-forward if there is anything to take — see Model.update_repo).- actions = QHBoxLayout()- actions.setSpacing(8)- self.download_btn = QPushButton(self.m.t('repo.download'))- self._translatable.append((self.download_btn, 'repo.download'))- self.download_btn.clicked.connect(lambda: self.m.clone_repo())- self.update_btn = QPushButton(self.m.t('repo.update'))- self._translatable.append((self.update_btn, 'repo.update'))- self.update_btn.clicked.connect(self.m.update_repo)- for b in (self.download_btn, self.update_btn):- actions.addWidget(b)- actions.addStretch(1)- lay.addLayout(actions)- self.repo_status = QLabel('')- self.repo_status.setObjectName('note')- lay.addWidget(self.repo_status)- # The engine's online sync (first start, after updates): a status line while it runs, and its failure row with Try again.- self.engine_status = QLabel('')- self.engine_status.setObjectName('note')- self.engine_status.setWordWrap(True)- self.engine_status.hide()- lay.addWidget(self.engine_status)- self.engine_failure_box = QFrame()- self.engine_failure_box.setObjectName('card')- fbox = QVBoxLayout(self.engine_failure_box)- fbox.setContentsMargins(12, 8, 12, 8)- fbox.setSpacing(4)- self.engine_failure_what = QLabel('')- self.engine_failure_what.setWordWrap(True)- self.engine_failure_what.setStyleSheet(f'color: {ORANGE}; font-weight: 600;')- self.engine_failure_next = QLabel('')- self.engine_failure_next.setWordWrap(True)- self.engine_failure_next.setObjectName('note')- self.engine_retry_btn = QPushButton(self.m.t('fail.retry'))- self._translatable.append((self.engine_retry_btn, 'fail.retry'))- self.engine_retry_btn.clicked.connect(self.m.retry_engine_sync)- retry_row = QHBoxLayout()- retry_row.addWidget(self.engine_retry_btn)- retry_row.addStretch(1)- fbox.addWidget(self.engine_failure_what)- fbox.addWidget(self.engine_failure_next)- fbox.addLayout(retry_row)- self.engine_failure_box.hide()- lay.addWidget(self.engine_failure_box)-- def _show_engine_sync(self) -> None:- """The status line while tools/engine.py sync runs, or its failure row (what happened, what to do, Try again)."""- self.engine_status.setVisible(self.m.engine_syncing)- self.engine_status.setText(self.m.t('engine.syncing') if self.m.engine_syncing else '')+ self.engine_retry_btn = QPushButton()+ self.engine_retry_btn.clicked.connect(lambda: self.m.sync_engine())+ row.addWidget(self.engine_retry_btn)+ row.addStretch(1)+ col.addLayout(row)+ box.hide()+ return box++ def _refresh_engine_banner(self) -> None:f = self.m.engine_failure- if f is None or self.m.engine_syncing:- self.engine_failure_box.hide()+ if self.m.engine_syncing:+ self.engine_sync_label.setText(self.m.t('engine.syncing'))+ self.engine_sync_label.show()+ self.engine_fail_what.hide()+ self.engine_fail_next.hide()+ self.engine_retry_btn.hide()+ self.engine_banner.show()+ elif f is not None:+ self.engine_sync_label.hide()+ self.engine_fail_what.setText(self.m.t(f.what_key))+ self.engine_fail_next.setText(self.m.t(f.next_key))+ self.engine_retry_btn.setText(self.m.t('fail.retry'))+ self.engine_fail_what.show()+ self.engine_fail_next.show()+ self.engine_retry_btn.show()+ self.engine_banner.show()+ else:+ self.engine_banner.hide()++ # ================================================================ Page 0: Library++ def _build_library_page(self) -> QWidget:+ page = QWidget()+ lay = QVBoxLayout(page)+ lay.setContentsMargins(0, 0, 0, 0)+ lay.setSpacing(0)++ self.lib_stack = QStackedWidget()++ # 0A: Empty Library Welcome State (mirrors emptyLibrary in LauncherView+Library.swift)+ empty = QWidget()+ ecol = QVBoxLayout(empty)+ ecol.setContentsMargins(40, 60, 40, 60)+ ecol.setSpacing(14)+ ecol.addStretch(1)++ icon_lbl = QLabel('🎮')+ icon_lbl.setAlignment(Qt.AlignCenter)+ icon_lbl.setStyleSheet('font-size: 46px;')+ ecol.addWidget(icon_lbl)++ self.lib_welcome_title = QLabel(self.m.t('library.welcome'))+ self.lib_welcome_title.setAlignment(Qt.AlignCenter)+ self.lib_welcome_title.setStyleSheet('font-size: 40px; font-weight: 800; color: #ffffff;')+ ecol.addWidget(self.lib_welcome_title)++ self.lib_welcome_note = QLabel(self.m.t('library.welcomeNote'))+ self.lib_welcome_note.setObjectName('pageNote')+ self.lib_welcome_note.setAlignment(Qt.AlignCenter)+ self.lib_welcome_note.setWordWrap(True)+ ecol.addWidget(self.lib_welcome_note)+ ecol.addSpacing(10)++ btn_row = QHBoxLayout()+ btn_row.addStretch(1)+ self.lib_first_build_btn = QPushButton('+ ' + self.m.t('library.firstBuild'))+ self.lib_first_build_btn.setObjectName('primary')+ self.lib_first_build_btn.setCursor(Qt.PointingHandCursor)+ self.lib_first_build_btn.clicked.connect(lambda: self._switch_page('builds'))+ btn_row.addWidget(self.lib_first_build_btn)++ self.lib_choose_folder_btn = QPushButton(self.m.t('library.chooseFolder'))+ self.lib_choose_folder_btn.setCursor(Qt.PointingHandCursor)+ self.lib_choose_folder_btn.clicked.connect(self._pick_library_folder)+ btn_row.addWidget(self.lib_choose_folder_btn)+ btn_row.addStretch(1)+ ecol.addLayout(btn_row)+ ecol.addStretch(1)+ self.lib_stack.addWidget(empty)++ # 0B: Populated Library (Hero showcase + Collection horizontal strip)+ pop = QWidget()+ pcol = QVBoxLayout(pop)+ pcol.setContentsMargins(0, 0, 0, 0)+ pcol.setSpacing(0)++ self.hero = HeroBannerWidget()+ self.hero.primaryClicked.connect(self._on_hero_primary)+ self.hero.manageClicked.connect(self._show_manage_menu)+ pcol.addWidget(self.hero, 1)++ # Collection section below Hero+ coll_wrap = QWidget()+ ccol = QVBoxLayout(coll_wrap)+ ccol.setContentsMargins(36, 14, 36, 20)+ ccol.setSpacing(12)++ chead = QHBoxLayout()+ chead.setSpacing(14)+ self.coll_title_lbl = QLabel(self.m.t('library.collection'))+ self.coll_title_lbl.setStyleSheet('font-size: 18px; font-weight: 800;')+ chead.addWidget(self.coll_title_lbl)++ self.coll_filter_seg = LauncherSegmented(+ [('owned', self.m.t('filter.owned')), ('built', self.m.t('filter.built'))],+ selected='owned',+ )+ self.coll_filter_seg.changed.connect(self._on_library_filter_changed)+ chead.addWidget(self.coll_filter_seg)++ self.coll_count_lbl = QLabel('')+ self.coll_count_lbl.setObjectName('muted')+ chead.addWidget(self.coll_count_lbl)+ chead.addStretch(1)++ self.rescan_lib_btn = QPushButton(self.m.t('library.rescan'))+ self.rescan_lib_btn.setObjectName('ghost')+ self.rescan_lib_btn.clicked.connect(self._rescan_library)+ chead.addWidget(self.rescan_lib_btn)++ scroll_left_btn = QPushButton('‹')+ scroll_left_btn.setFixedSize(30, 30)+ scroll_left_btn.setStyleSheet('padding: 0px; font-size: 16px; font-weight: 700;')+ scroll_left_btn.clicked.connect(lambda: self._scroll_collection(-1))+ scroll_right_btn = QPushButton('›')+ scroll_right_btn.setFixedSize(30, 30)+ scroll_right_btn.setStyleSheet('padding: 0px; font-size: 16px; font-weight: 700;')+ scroll_right_btn.clicked.connect(lambda: self._scroll_collection(1))+ chead.addWidget(scroll_left_btn)+ chead.addWidget(scroll_right_btn)+ ccol.addLayout(chead)++ self._coll_offset = 0+ self.coll_strip = QWidget()+ self.coll_strip.setFixedHeight(176)+ self.coll_strip_layout = QHBoxLayout(self.coll_strip)+ self.coll_strip_layout.setContentsMargins(0, 4, 0, 4)+ self.coll_strip_layout.setSpacing(18)+ ccol.addWidget(self.coll_strip)++ pcol.addWidget(coll_wrap)+ self.lib_stack.addWidget(pop)++ lay.addWidget(self.lib_stack, 1)+ return page++ def _filtered_games(self) -> list[lib.LibraryGame]:+ games = list(self.m.library.games)+ if self._library_filter == 'built':+ games = [g for g in games if g.has_any_build]+ if self._search_query:+ q = self._search_query.lower()+ games = [g for g in games if q in g.name.lower() or q in g.title_id.lower()]+ return games++ def _refresh_library(self) -> None:+ self.lib_welcome_title.setText(self.m.t('library.welcome'))+ self.lib_welcome_note.setText(self.m.t('library.welcomeNote'))+ self.lib_first_build_btn.setText('+ ' + self.m.t('library.firstBuild'))+ self.lib_choose_folder_btn.setText(self.m.t('library.chooseFolder'))+ self.coll_title_lbl.setText(self.m.t('library.collection'))+ self.coll_filter_seg.set_items(+ [('owned', self.m.t('filter.owned')), ('built', self.m.t('filter.built'))],+ selected=self._library_filter,+ )+ self.rescan_lib_btn.setText(self.m.t('library.rescan'))++ if not self.m.library.games:+ self.lib_stack.setCurrentIndex(0)return- self.engine_failure_what.setText(self.m.t(f.what_key))- self.engine_failure_next.setText(self.m.t(f.next_key))- self.engine_failure_box.show()-- def _build_inputs(self) -> None:- box, lay = self._card('data.title', 'data.note')- self.data_box = box- self.folder_label = QLabel(self.m.t('data.folderHint'))- self.folder_label.setObjectName('mono')- lay.addWidget(self.folder_label)- grid = QGridLayout()- grid.setHorizontalSpacing(8)- grid.setVerticalSpacing(4)- grid.setColumnStretch(2, 1)- self.input_rows: dict[str, tuple[QLabel, QLabel]] = {}- specs = [('base', 'data.base', False), ('update', 'data.update', True),- ('dlc', 'data.dlc', True), ('keys', 'data.keys', False)]- for i, (key, l10n, optional) in enumerate(specs):- dot = QLabel('○')- dot.setFixedWidth(14)- name = QLabel(self.m.t(l10n))- name.setFixedWidth(110)- self._translatable.append((name, l10n))- val = QLabel('—')- val.setObjectName('mono')- val.setTextInteractionFlags(Qt.TextSelectableByMouse)- val.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Preferred) # filenames are long; the Choose button must stay visible- btn = QPushButton(self.m.t('data.choose'))- self._translatable.append((btn, 'data.choose'))- btn.setFixedWidth(72)- btn.clicked.connect(lambda _=False, k=key: self._choose_input(k))- grid.addWidget(dot, i, 0)- grid.addWidget(name, i, 1)- grid.addWidget(val, i, 2)- grid.addWidget(btn, i, 3)- self.input_rows[key] = (dot, val)- lay.addLayout(grid)- row = QHBoxLayout()- row.addStretch(1)- pick = QPushButton(self.m.t('data.pickFolder'))- self._translatable.append((pick, 'data.pickFolder'))- pick.clicked.connect(self._pick_folder)- row.addWidget(pick)- lay.addLayout(row)-- def _build_deps(self) -> None:- box, lay = self._card('dep.title')- self.deps_box = box- head = QHBoxLayout()- self.deps_summary = QLabel('')- head.addWidget(self.deps_summary)- head.addStretch(1)- self.install_all_btn = QPushButton(self.m.t('dep.installAll'))- self._translatable.append((self.install_all_btn, 'dep.installAll'))- self.install_all_btn.clicked.connect(self.m.install_all_missing)- head.addWidget(self.install_all_btn)- recheck = QPushButton(self.m.t('dep.recheck'))- self._translatable.append((recheck, 'dep.recheck'))- recheck.clicked.connect(self.m.check_deps)- head.addWidget(recheck)- self.deps_toggle = QPushButton(self.m.t('dep.hide'))- self._translatable.append((self.deps_toggle, 'dep.hide'))- self.deps_toggle.clicked.connect(self._toggle_deps)- head.addWidget(self.deps_toggle)- lay.addLayout(head)- self.deps_container = QVBoxLayout()- self.deps_container.setSpacing(3)- lay.addLayout(self.deps_container)- # Open by default, like the Mac's panel (open while anything is missing); remembered for- # the next start either way.- self.deps_open = self.m.settings_value('depsExpanded')- self._apply_deps_open()-- def _toggle_deps(self) -> None:- self.deps_open = not self.deps_open- self.m.settings_set('depsExpanded', self.deps_open)- self._apply_deps_open()-- def _apply_deps_open(self) -> None:- for i in range(self.deps_container.count()):- if w := self.deps_container.itemAt(i).widget():- w.setVisible(self.deps_open)- self.deps_toggle.setText(self.m.t('dep.hide' if self.deps_open else 'dep.show'))- self._translatable = [(w, k) if k != 'dep.hide' and w is not self.deps_toggle else (w, 'dep.hide' if self.deps_open else 'dep.show')- for w, k in self._translatable]-- def _build_progress(self) -> None:- box, lay = self._card('prog.title')- self.progress_box = box- self.progress_box.setVisible(False)- self.overall = QProgressBar()- self.overall.setTextVisible(False)- lay.addWidget(self.overall)- self.stages_container = QVBoxLayout()- self.stages_container.setSpacing(3)- lay.addLayout(self.stages_container)-- def _build_log(self) -> None:- head = QHBoxLayout()- head.setSpacing(6)- self.log_path_label = QLabel('')- self.log_path_label.setObjectName('note')- self.log_path_label.setTextInteractionFlags(Qt.TextSelectableByMouse)- self.log_path_label.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Preferred)- head.addWidget(self.log_path_label, 1)- self.export_btn = QPushButton(self.m.t('log.export'))- self._translatable.append((self.export_btn, 'log.export'))- self.export_btn.clicked.connect(self._export_log)- head.addWidget(self.export_btn)- self.body.addLayout(head)- self.log = QTextEdit()- self.log.setReadOnly(True)- self.log.setFont(self._mono)- self.log.setPlaceholderText(self.m.t('log.placeholder'))- self.log.setMinimumHeight(90)- self.log.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)- self.body.addWidget(self.log, 1)- def _build_footer(self) -> None:- wrap = QWidget()- outer = QVBoxLayout(wrap)- outer.setContentsMargins(0, 0, 0, 0)- outer.setSpacing(2)- row = QHBoxLayout()- row.setContentsMargins(12, 6, 12, 4)- row.setSpacing(10)+ self.lib_stack.setCurrentIndex(1)+ filtered = self._filtered_games()+ self.coll_count_lbl.setText(self.m.t('library.gameCount', len(filtered)))++ sel = self.m.library.selected+ if sel not in filtered and filtered:+ sel = filtered[0]+ self.m.library.select(sel.title_id)++ if sel:+ if self.m.running and self.m.build_key.upper() == sel.title_id.upper():+ st_text = self.m.t('library.building')+ st_color = style.AMBER+ p_label = self.m.t('library.viewBuild')+ p_en = True+ elif sel.has_ipa or sel.has_archive:+ st_text = self.m.t('library.readyIOS')+ st_color = style.GREEN+ p_label = self.m.t('install.reveal')+ p_en = True+ else:+ st_text = self.m.t('library.notBuilt')+ st_color = style.NEUTRAL_DOT+ p_label = self.m.t('build.startGame')+ p_en = not self.m.running++ sub_parts = [sel.title_id]+ if sel.has_ipa:+ sub_parts.append(sel.ipa_path)+ elif sel.inputs.get('base'):+ sub_parts.append(sel.inputs['base'][0])++ art = self.m.artwork.image_path(sel.title_id, self.m.engine_path)+ self.hero.set_data(+ title_id=sel.title_id,+ title=sel.name,+ subtitle=' · '.join(sub_parts),+ status_text=st_text,+ status_color=st_color,+ primary_label=p_label,+ primary_enabled=p_en,+ manage_label=self.m.t('library.manage'),+ image_path=art,+ is_switch2=sel.is_switch2(self.m.engine_path),+ switch2_label=self.m.t('switch2.badge'),+ )++ # Rebuild horizontal strip+ while self.coll_strip_layout.count():+ it = self.coll_strip_layout.takeAt(0)+ w_old = it.widget()+ if w_old:+ w_old.hide()+ w_old.setParent(None)+ w_old.deleteLater()++ if not filtered:+ no_lbl = QLabel(self.m.t('library.noResults'))+ no_lbl.setObjectName('muted')+ self.coll_strip_layout.addWidget(no_lbl)+ else:+ for g in filtered:+ dot_c = style.GREEN if g.has_any_build else style.NEUTRAL_DOT+ art = self.m.artwork.image_path(g.title_id, self.m.engine_path)+ card = GameCardWidget(+ title_id=g.title_id,+ title=g.name,+ image_path=art,+ selected=(sel is not None and g.title_id == sel.title_id),+ dot_color=dot_c,+ is_switch2=g.is_switch2(self.m.engine_path),+ switch2_label=self.m.t('switch2.badge'),+ )+ card.clicked.connect(self._on_card_selected)+ card.doubleClicked.connect(self._on_card_double_clicked)+ self.coll_strip_layout.addWidget(card)+ self.coll_strip_layout.addStretch(1)++ def _on_card_selected(self, title_id: str) -> None:+ self.m.library.select(title_id)+ self._refresh_library()++ def _on_card_double_clicked(self, title_id: str) -> None:+ self.m.library.select(title_id)+ g = self.m.library.selected+ if g:+ self.m.load_game_from_library(g)+ self._switch_page('builds')++ def _on_hero_primary(self) -> None:+ g = self.m.library.selected+ if not g:+ return+ if self.m.running and self.m.build_key.upper() == g.title_id.upper():+ self._switch_page('builds')+ return+ if g.has_ipa:+ pu.reveal(g.ipa_path)+ elif g.has_archive:+ pu.reveal(g.archive_path)+ else:+ self.m.load_game_from_library(g)+ self._switch_page('builds')++ def _show_manage_menu(self, anchor: QWidget) -> None:+ g = self.m.library.selected+ if not g:+ return+ menu = QMenu(self)+ menu.setStyleSheet(+ f'QMenu {{ background: #1c1c1f; color: {style.TEXT}; border: 1px solid {style.BORDER}; '+ f'border-radius: 10px; padding: 6px; }} '+ f'QMenu::item {{ padding: 7px 18px; border-radius: 6px; }} '+ f'QMenu::item:selected {{ background: rgba(255,255,255,0.12); }}'+ )++ act_build = menu.addAction(self.m.t('library.buildAgain') if g.has_any_build else self.m.t('build.startGame'))+ act_build.triggered.connect(lambda: (self.m.load_game_from_library(g), self._switch_page('builds')))++ act_cheats = menu.addAction(self.m.t('cheats.menu'))+ act_cheats.triggered.connect(lambda: CheatsDialog(self.m, g, self).exec())++ act_art = menu.addAction(self.m.t('library.changeArtwork'))+ act_art.triggered.connect(lambda: self._pick_custom_artwork(g))++ if self.m.artwork.has_custom(g.title_id):+ act_reset_art = menu.addAction(self.m.t('library.resetArtwork'))+ act_reset_art.triggered.connect(lambda: (self.m.artwork.clear_custom(g.title_id), self._refresh_library()))++ target_reveal = g.ipa_path if g.has_ipa else (g.archive_path if g.has_archive else ((g.inputs.get('base') or [''])[0]))+ if target_reveal and os.path.exists(target_reveal):+ act_reveal = menu.addAction(self.m.t('install.reveal'))+ act_reveal.triggered.connect(lambda: pu.reveal(target_reveal))++ act_free = menu.addAction(self.m.t('free.menu'))+ act_free.triggered.connect(lambda: FreeSpaceDialog(self.m, g, self).exec())++ menu.addSeparator()++ act_remove = menu.addAction(self.m.t('library.remove'))+ act_remove.triggered.connect(lambda: (self.m.library.remove(g.title_id), self._refresh_library()))++ act_delete = menu.addAction(self.m.t('delete.menu'))+ act_delete.triggered.connect(lambda: self._delete_game_dialog(g))++ menu.exec(anchor.mapToGlobal(anchor.rect().bottomLeft()))++ def _pick_custom_artwork(self, game: lib.LibraryGame) -> None:+ f, _ = QFileDialog.getOpenFileName(+ self,+ self.m.t('library.changeArtwork'),+ '',+ 'Images (*.png *.jpg *.jpeg *.webp)',+ )+ if f:+ self.m.artwork.set_custom(game.title_id, f)+ self._refresh_library()++ def _delete_game_dialog(self, game: lib.LibraryGame) -> None:+ dlg = DeleteGameDialog(self.m, game, self)+ dlg.exec()+ if dlg.confirmed:+ self._refresh_library()++ def _on_library_filter_changed(self, flt: str) -> None:+ self._library_filter = flt+ self._refresh_library()++ def _on_search_changed(self, text: str) -> None:+ self._search_query = text.strip()+ if self._current_page == 'library':+ self._refresh_library()++ def _scroll_collection(self, direction: int) -> None:+ filtered = self._filtered_games()+ if not filtered:+ return+ self._coll_offset = max(0, min(max(0, len(filtered) - 1), self._coll_offset + direction))+ self.m.library.select(filtered[self._coll_offset].title_id)+ self._refresh_library()++ def _pick_library_folder(self) -> None:+ d = QFileDialog.getExistingDirectory(+ self,+ self.m.t('library.folderTitle'),+ self.m.library.games_folder or str(Path.home()),+ )+ if d:+ self.m.library.set_games_folder(d, repo_path=self.m.engine_path, default_keys=self.m.keys_path)+ for g in self.m.library.games:+ self.m.artwork.request_banner_async(g.title_id)+ self._refresh_all()++ def _rescan_library(self) -> None:+ if not self.m.library.games_folder:+ self._pick_library_folder()+ return+ self.m.library.rescan_games_folder(repo_path=self.m.engine_path, default_keys=self.m.keys_path)+ for g in self.m.library.games:+ self.m.artwork.request_banner_async(g.title_id)+ self._refresh_library()++ # ================================================================ Page 1: Builds++ def _build_builds_page(self) -> QWidget:+ body = QWidget()+ self.body_col = QVBoxLayout(body)+ self.body_col.setContentsMargins(40, 28, 40, 36)+ self.body_col.setSpacing(20)++ # Page heading+ self.build_heading = CardPageHeading(self.m.t('build.heading'), self.m.t('build.intro'))+ self.body_col.addWidget(self.build_heading)++ # Setup Hint Card (shown when repo or required deps are not ready)+ self.setup_hint_card = self._build_setup_hint_card()+ self.body_col.addWidget(self.setup_hint_card)++ # Card 1: Game Files (FilesCard)+ self.files_group = self._build_files_card()+ self.body_col.addWidget(self.files_group)++ # Card 2: Play on / Target & BC texture option (TargetCard)+ self.target_group = self._build_target_card()+ self.body_col.addWidget(self.target_group)++ # Card 3: Install or Export / Shared App vs One-Game IPA + Drive Copy (InstallCard)+ self.install_group = self._build_install_card()+ self.body_col.addWidget(self.install_group)++ # Card 4: Action + BuildFailureCard + OutcomeCard+ self.action_group = self._build_action_card()+ self.body_col.addWidget(self.action_group)++ # Card 5: Progress Card+ self.stages_card = self._build_stages_card()+ self.body_col.addWidget(self.stages_card)++ # Card 6: Build Log Card (at the bottom of `self.scroll` so `test_build_failure.py` geometry checks pass)+ self.log_group = self._build_log_card()+ self.body_col.addWidget(self.log_group)++ self.body_col.addStretch(1)+ return body++ def _build_setup_hint_card(self) -> CardGroup:+ grp = CardGroup(title=self.m.t('section.setup'))+ r = QWidget()+ rl = QHBoxLayout(r)+ rl.setContentsMargins(18, 13, 18, 13)+ rl.setSpacing(12)+ self.setup_hint_dot = _dot(style.AMBER)+ rl.addWidget(self.setup_hint_dot)+ col = QVBoxLayout()+ col.setSpacing(2)+ self.setup_hint_title = QLabel(self.m.t('library.setupHint'))+ self.setup_hint_title.setObjectName('rowTitle')+ self.setup_hint_sub = QLabel('')+ self.setup_hint_sub.setObjectName('muted')+ self.setup_hint_sub.setWordWrap(True)+ col.addWidget(self.setup_hint_title)+ col.addWidget(self.setup_hint_sub)+ rl.addLayout(col, 1)+ self.setup_goto_btn = QPushButton(self.m.t('nav.settings'))+ self.setup_goto_btn.setObjectName('creamPill')+ self.setup_goto_btn.clicked.connect(lambda: self._switch_page('settings'))+ rl.addWidget(self.setup_goto_btn)+ grp.add_row(r)+ return grp++ def _build_files_card(self) -> CardGroup:+ grp = CardGroup(title=self.m.t('section.files'), footer=self.m.t('msg.workdirHint'))++ # Row 1: Game folder CTA (cream capsule button)+ r_folder = QWidget()+ rf_lay = QHBoxLayout(r_folder)+ rf_lay.setContentsMargins(18, 14, 18, 14)+ rf_lay.setSpacing(12)+ self.folder_cta_dot = _dot(style.NEUTRAL_DOT)+ rf_lay.addWidget(self.folder_cta_dot)+ fcol = QVBoxLayout()+ fcol.setSpacing(2)+ self.folder_cta_title = QLabel(self.m.t('build.folderCTA') + ' · ' + self.m.t('data.note'))+ self.folder_cta_title.setObjectName('rowTitle')+ self.folder_cta_sub = QLabel(self.m.t('build.folderNote') + ' (' + self.m.t('data.folderHint') + ')')+ self.folder_cta_sub.setObjectName('muted')+ self.folder_cta_sub.setWordWrap(True)+ fcol.addWidget(self.folder_cta_title)+ fcol.addWidget(self.folder_cta_sub)+ rf_lay.addLayout(fcol, 1)+ self.pick_folder_btn = QPushButton(self.m.t('data.pickFolder'))+ self.pick_folder_btn.setObjectName('creamPill')+ self.pick_folder_btn.setFixedWidth(184)+ self.pick_folder_btn.clicked.connect(self._pick_game_dir)+ rf_lay.addWidget(self.pick_folder_btn)+ grp.add_row(r_folder)+ grp.add_divider()++ self.input_rows: dict[str, dict] = {}++ # Row 2 & 3: Required slots (base, keys)+ for idx, (key, title_key, req, multi) in enumerate([+ ('base', 'data.base', True, False),+ ('keys', 'data.keys', True, False),+ ]):+ if idx > 0:+ grp.add_divider()+ grp.add_row(self._make_input_slot_row(key, title_key, req, multi))++ # KeyCheck live verification row (under prod.keys)+ self.keycheck_row = QWidget()+ kc_lay = QHBoxLayout(self.keycheck_row)+ kc_lay.setContentsMargins(38, 4, 18, 10)+ kc_lay.setSpacing(8)+ self.keycheck_dot = _dot(style.GREEN)+ self.keycheck_lbl = QLabel('')+ self.keycheck_lbl.setObjectName('muted')+ self.keycheck_lbl.setWordWrap(True)+ kc_lay.addWidget(self.keycheck_dot)+ kc_lay.addWidget(self.keycheck_lbl, 1)+ self.keycheck_row.hide()+ grp.add_row(self.keycheck_row)+ grp.add_divider()++ # Row 4: Disclosure for Updates & DLC (optional)+ disc_head = QWidget()+ dh_lay = QHBoxLayout(disc_head)+ dh_lay.setContentsMargins(18, 10, 18, 10)+ self.opt_toggle_btn = QPushButton('▾ ' + self.m.t('build.options'))+ self.opt_toggle_btn.setObjectName('ghost')+ self.opt_toggle_btn.clicked.connect(self._toggle_optional_inputs)+ dh_lay.addWidget(self.opt_toggle_btn)+ dh_lay.addStretch(1)+ grp.add_row(disc_head)++ self.opt_container = QWidget()+ opt_col = QVBoxLayout(self.opt_container)+ opt_col.setContentsMargins(0, 0, 0, 0)+ opt_col.setSpacing(0)+ opt_col.addWidget(self._make_input_slot_row('update', 'data.update', False, False))+ opt_col.addWidget(self._make_input_slot_row('dlc', 'data.dlc', False, True))+ grp.add_row(self.opt_container)+ grp.add_divider()++ # Row 5: Output folder (build.saveTo)+ out_row = QWidget()+ or_lay = QHBoxLayout(out_row)+ or_lay.setContentsMargins(18, 12, 18, 12)+ or_lay.setSpacing(12)+ or_lay.addWidget(_dot(style.NEUTRAL_DOT))+ ocol = QVBoxLayout()+ ocol.setSpacing(2)+ self.out_title_lbl = QLabel(self.m.t('build.saveTo'))+ self.out_title_lbl.setObjectName('rowTitle')+ self.out_label = QLabel(self.m.t('build.saveDefault'))+ self.out_label.setObjectName('mono')+ ocol.addWidget(self.out_title_lbl)+ ocol.addWidget(self.out_label)+ or_lay.addLayout(ocol, 1)+ self.out_clear_btn = QPushButton(self.m.t('data.clear'))+ self.out_clear_btn.setObjectName('ghost')+ self.out_clear_btn.clicked.connect(self._clear_out_dir)+ self.out_clear_btn.hide()+ or_lay.addWidget(self.out_clear_btn)+ self.out_btn = QPushButton(self.m.t('build.outDir'))+ self.out_btn.setFixedWidth(184)+ self.out_btn.clicked.connect(self._pick_out_dir)+ or_lay.addWidget(self.out_btn)+ grp.add_row(out_row)++ return grp++ def _make_input_slot_row(self, key: str, title_key: str, req: bool, multi: bool) -> QWidget:+ w = QWidget()+ r = QHBoxLayout(w)+ r.setContentsMargins(18, 11, 18, 11)+ r.setSpacing(12)+ dot = _dot(style.NEUTRAL_DOT)+ r.addWidget(dot)+ col = QVBoxLayout()+ col.setSpacing(2)+ title = QLabel(self.m.t(title_key))+ title.setObjectName('rowTitle')+ path = QLabel()+ path.setObjectName('mono')+ path.setWordWrap(True)+ col.addWidget(title)+ col.addWidget(path)+ r.addLayout(col, 1)++ clear = QPushButton(self.m.t('data.clear'))+ clear.setObjectName('ghost')+ clear.clicked.connect(lambda _=False, k=key: self._clear_input(k))+ r.addWidget(clear)++ choose = QPushButton(self.m.t('data.choose'))+ choose.setFixedWidth(184)+ choose.clicked.connect(lambda _=False, k=key, m=multi: self._pick_input(k, m))+ r.addWidget(choose)++ self.input_rows[key] = {+ 'dot': dot,+ 'title': title,+ 'title_key': title_key,+ 'path': path,+ 'clear': clear,+ 'choose': choose,+ 'req': req,+ }+ return w++ def _toggle_optional_inputs(self) -> None:+ self._options_expanded = not self._options_expanded+ self.opt_container.setVisible(self._options_expanded)+ arrow = '▾' if self._options_expanded else '▸'+ self.opt_toggle_btn.setText(f"{arrow} {self.m.t('build.options')}")++ def _build_target_card(self) -> CardGroup:+ grp = CardGroup(title=self.m.t('section.target'))++ # Platform row+ r_plat = QWidget()+ rp_lay = QHBoxLayout(r_plat)+ rp_lay.setContentsMargins(18, 12, 18, 12)+ rp_lay.setSpacing(12)+ rp_lay.addWidget(_dot(style.GREEN))+ pcol = QVBoxLayout()+ pcol.setSpacing(2)+ self.target_title_lbl = QLabel(self.m.t('build.ios'))+ self.target_title_lbl.setObjectName('rowTitle')+ self.target_hint = QLabel(self.m.t('build.iosNote'))+ self.target_hint.setObjectName('muted')+ self.target_hint.setWordWrap(True)+ pcol.addWidget(self.target_title_lbl)+ pcol.addWidget(self.target_hint)+ rp_lay.addLayout(pcol, 1)++ self.target_btn = QPushButton()+ self.target_btn.clicked.connect(self._toggle_target)+ if pu.IS_WIN:+ self.target_btn.hide()+ rp_lay.addWidget(self.target_btn)+ grp.add_row(r_plat)+ grp.add_divider()++ # Older devices BC texture CPU decode row (opt.bc)+ r_bc = QWidget()+ rbc_lay = QHBoxLayout(r_bc)+ rbc_lay.setContentsMargins(18, 12, 18, 12)+ rbc_lay.setSpacing(12)+ rbc_lay.addWidget(_dot(style.NEUTRAL_DOT))+ bccol = QVBoxLayout()+ bccol.setSpacing(2)+ self.bc_title_lbl = QLabel(self.m.t('opt.bc'))+ self.bc_title_lbl.setObjectName('rowTitle')+ self.bc_note_lbl = QLabel(self.m.t('opt.bc.note'))+ self.bc_note_lbl.setObjectName('muted')+ self.bc_note_lbl.setWordWrap(True)+ bccol.addWidget(self.bc_title_lbl)+ bccol.addWidget(self.bc_note_lbl)+ rbc_lay.addLayout(bccol, 1)+ self.bc_switch = LauncherSwitch(self.m.bc_on_cpu)+ self.bc_switch.toggled.connect(self._on_bc_toggled)+ rbc_lay.addWidget(self.bc_switch)+ grp.add_row(r_bc)++ return grp++ def _on_bc_toggled(self, checked: bool) -> None:+ self.m.bc_on_cpu = checked++ def _build_install_card(self) -> CardGroup:+ grp = CardGroup(title=self.m.t('dev.section'))++ # Row 1: What the IPA holds (Shared app vs One game, all inside)+ r_kind = QWidget()+ rk_lay = QHBoxLayout(r_kind)+ rk_lay.setContentsMargins(18, 12, 18, 12)+ rk_lay.setSpacing(12)+ rk_lay.addWidget(_dot(style.GREEN))+ kcol = QVBoxLayout()+ kcol.setSpacing(2)+ self.ipa_kind_title = QLabel(self.m.t('shell.ipaKind'))+ self.ipa_kind_title.setObjectName('rowTitle')+ self.ipa_kind_note = QLabel(self.m.t('shell.ipaSharedNote'))+ self.ipa_kind_note.setObjectName('muted')+ self.ipa_kind_note.setWordWrap(True)+ kcol.addWidget(self.ipa_kind_title)+ kcol.addWidget(self.ipa_kind_note)+ rk_lay.addLayout(kcol, 1)++ self.ipa_kind_seg = LauncherSegmented(+ [+ ('shared', self.m.t('shell.ipaShared')),+ ('oneGame', self.m.t('shell.ipaOneGame')),+ ],+ selected=self.m.ipa_kind,+ )+ self.ipa_kind_seg.changed.connect(self._on_ipa_kind_changed)+ rk_lay.addWidget(self.ipa_kind_seg)+ grp.add_row(r_kind)+ grp.add_divider()++ # Step 1: Export IPA+ r_s1 = QWidget()+ rs1_lay = QHBoxLayout(r_s1)+ rs1_lay.setContentsMargins(18, 11, 18, 11)+ rs1_lay.setSpacing(10)+ s1_col = QVBoxLayout()+ self.step1_title = QLabel('① ' + self.m.t('shell.step1Title'))+ self.step1_title.setObjectName('rowTitle')+ self.step1_sub = QLabel(self.m.t('shell.step1Sub'))+ self.step1_sub.setObjectName('muted')+ self.step1_sub.setWordWrap(True)+ s1_col.addWidget(self.step1_title)+ s1_col.addWidget(self.step1_sub)+ rs1_lay.addLayout(s1_col, 1)++ self.step1_reveal_btn = QPushButton(self.m.t('shell.showInFinder'))+ self.step1_reveal_btn.clicked.connect(lambda: pu.reveal(self._effective_ipa_path()))+ self.step1_reveal_btn.hide()+ rs1_lay.addWidget(self.step1_reveal_btn)+ grp.add_row(r_s1)+ grp.add_divider()++ # Step 2: Install with your own tool (AltStore / SideStore)+ r_s2 = QWidget()+ rs2_lay = QHBoxLayout(r_s2)+ rs2_lay.setContentsMargins(18, 11, 18, 11)+ s2_col = QVBoxLayout()+ self.step2_title = QLabel('② ' + self.m.t('shell.step2Title'))+ self.step2_title.setObjectName('rowTitle')+ self.step2_sub = QLabel(self.m.t('shell.step2Sub'))+ self.step2_sub.setObjectName('muted')+ self.step2_sub.setWordWrap(True)+ s2_col.addWidget(self.step2_title)+ s2_col.addWidget(self.step2_sub)+ rs2_lay.addLayout(s2_col, 1)+ grp.add_row(r_s2)++ # Step 3: Send game data to drive or folder (shown when shared app mode)+ self.step3_container = QWidget()+ s3_outer = QVBoxLayout(self.step3_container)+ s3_outer.setContentsMargins(0, 0, 0, 0)+ s3_outer.setSpacing(0)+ s3_outer.addWidget(make_divider())++ r_s3 = QWidget()+ rs3_lay = QHBoxLayout(r_s3)+ rs3_lay.setContentsMargins(18, 11, 18, 11)+ rs3_lay.setSpacing(10)+ s3_col = QVBoxLayout()+ s3_col.setSpacing(3)+ self.step3_title = QLabel('③ ' + self.m.t('shell.step3Title') + ' · ' + self.m.t('shell.whereDrive'))+ self.step3_title.setObjectName('rowTitle')+ self.drive_path_lbl = QLabel(self.m.t('shell.driveNone'))+ self.drive_path_lbl.setObjectName('mono')+ self.drive_path_lbl.setWordWrap(True)+ self.step3_sub = QLabel(self.m.t('shell.copyExternalNote'))+ self.step3_sub.setObjectName('muted')+ self.step3_sub.setWordWrap(True)+ s3_col.addWidget(self.step3_title)+ s3_col.addWidget(self.drive_path_lbl)+ s3_col.addWidget(self.step3_sub)+ rs3_lay.addLayout(s3_col, 1)++ self.step3_open_romfs_btn = QPushButton(self.m.t('shell.showInFinder'))+ self.step3_open_romfs_btn.clicked.connect(lambda: pu.reveal(self._effective_archive_path()))+ self.step3_open_romfs_btn.hide()+ rs3_lay.addWidget(self.step3_open_romfs_btn)++ self.drive_choose_btn = QPushButton(self.m.t('shell.driveChoose'))+ self.drive_choose_btn.clicked.connect(self._pick_drive_folder)+ rs3_lay.addWidget(self.drive_choose_btn)++ self.drive_copy_btn = QPushButton(self.m.t('shell.driveCopy'))+ self.drive_copy_btn.setObjectName('creamPill')+ self.drive_copy_btn.clicked.connect(self._copy_archive_to_drive)+ rs3_lay.addWidget(self.drive_copy_btn)+ s3_outer.addWidget(r_s3)+ grp.add_row(self.step3_container)++ return grp++ def _effective_ipa_path(self) -> str:+ if self.m.ipa_path and os.path.exists(self.m.ipa_path):+ return self.m.ipa_path+ tid = self.m.build_key+ if tid and self.m.out_dir:+ cand = os.path.join(self.m.out_dir, f'{tid}.ipa')+ if os.path.isfile(cand):+ return cand+ sel = self.m.library.selected+ if sel and sel.has_ipa:+ return sel.ipa_path+ return self.m.ipa_path++ def _effective_archive_path(self) -> str:+ if self.m.archive_path and os.path.isdir(self.m.archive_path):+ return self.m.archive_path+ if self.m.out_dir:+ cand = os.path.join(self.m.out_dir, 'romfs')+ if os.path.isdir(cand):+ return cand+ sel = self.m.library.selected+ if sel and sel.has_archive:+ return sel.archive_path+ return self.m.archive_path++ def _on_ipa_kind_changed(self, kind: str) -> None:+ self.m.ipa_kind = kind+ self._refresh_install_card()++ def _refresh_install_card(self) -> None:+ self.install_group.set_title(self.m.t('dev.section'))+ self.ipa_kind_title.setText(self.m.t('shell.ipaKind'))+ self.ipa_kind_seg.set_items(+ [+ ('shared', self.m.t('shell.ipaShared')),+ ('oneGame', self.m.t('shell.ipaOneGame')),+ ],+ selected=self.m.ipa_kind,+ )+ one = self.m.ipa_kind == 'oneGame'+ self.ipa_kind_note.setText(self.m.t('shell.ipaOneGameNote' if one else 'shell.ipaSharedNote'))+ self.step1_title.setText('① ' + self.m.t('shell.step1Title'))+ self.step1_sub.setText(self.m.t('shell.oneGameSub' if one else 'shell.step1Sub'))+ ipa_p = self._effective_ipa_path()+ has_ipa = bool(ipa_p and os.path.exists(ipa_p))+ self.step1_reveal_btn.setText(self.m.t('shell.showInFinder'))+ self.step1_reveal_btn.setToolTip(self.m.t('msg.ipaAt', ipa_p) if has_ipa else '')+ self.step1_reveal_btn.setVisible(has_ipa)+ self.step2_title.setText('② ' + self.m.t('shell.step2Title'))+ self.step2_sub.setText(self.m.t('shell.oneGameStep2Sub' if one else 'shell.step2Sub'))+ self.step3_title.setText('③ ' + self.m.t('shell.step3Title') + ' · ' + self.m.t('shell.whereDrive'))+ self.drive_path_lbl.setText(self._drive_folder or self.m.t('shell.driveNone'))+ self.step3_open_romfs_btn.setText(self.m.t('shell.showInFinder'))+ self.drive_choose_btn.setText(self.m.t('shell.driveChoose'))+ self.drive_copy_btn.setText(self.m.t('shell.driveCopy'))+ self.step3_container.setVisible(not one)+ arch_p = self._effective_archive_path()+ has_arch = bool(arch_p and os.path.isdir(arch_p))+ self.step3_open_romfs_btn.setToolTip(self.m.t('msg.archiveAt', arch_p) if has_arch else '')+ self.step3_open_romfs_btn.setVisible(has_arch)+ self.drive_copy_btn.setEnabled(has_arch)++ def _pick_drive_folder(self) -> None:+ d = QFileDialog.getExistingDirectory(self, self.m.t('shell.driveChoose'), self._drive_folder or str(Path.home()))+ if d:+ self._drive_folder = d+ self.drive_path_lbl.setText(d)+ self._refresh_install_card()++ def _copy_archive_to_drive(self) -> None:+ arch_p = self._effective_archive_path()+ if not arch_p or not os.path.isdir(arch_p):+ return+ if not self._drive_folder:+ d = QFileDialog.getExistingDirectory(self, self.m.t('shell.driveChoose'), str(Path.home()))+ if not d:+ return+ self._drive_folder = d+ self.drive_path_lbl.setText(d)+ tid = self.m.build_key+ ok, info = lib.DriveCopy.copy_to_folder(arch_p, self._drive_folder, tid)+ if ok:+ self.step3_sub.setText(self.m.t('shell.driveDone', info, self.m.t('ios.ui.gameData')))+ else:+ self.step3_sub.setText(self.m.t('shell.driveFailed', info))++ def _build_action_card(self) -> CardGroup:+ grp = CardGroup()+ r = QWidget()+ act = QHBoxLayout(r)+ act.setContentsMargins(18, 14, 18, 14)+ act.setSpacing(12)+self.build_btn = QPushButton(self.m.t('build.start'))self.build_btn.setObjectName('primary')- self.build_btn.setMinimumWidth(110)+ self.build_btn.setMinimumWidth(190)self.build_btn.clicked.connect(self._build_clicked)- row.addWidget(self.build_btn)+ act.addWidget(self.build_btn)+self.footer = QLabel('')- self.footer.setObjectName('footer')- row.addWidget(self.footer, 1)- # Output target. A Mac app only exists on macOS (dm/mac/pack_app.py), so the choice is- # hidden elsewhere rather than shown and rejected.- if not pu.IS_WIN:- self.target_btn = QPushButton(self.m.t('target.ios'))- self.target_btn.setToolTip(self.m.t('target.tip'))- self.target_btn.clicked.connect(self._toggle_target)- row.addWidget(self.target_btn)- self.out_btn = QPushButton(self.m.t('build.outDir'))- self._translatable.append((self.out_btn, 'build.outDir'))- self.out_btn.clicked.connect(self._choose_out)- row.addWidget(self.out_btn)- # the output folder silently decides where the build cache lives — the report changed it- # and lost a finished build; say it here, all the time- hint = QLabel(self.m.t('msg.workdirHint'))- hint.setObjectName('note')- hint.setWordWrap(True)- outer.addLayout(row)- self._build_failure_box(outer)- outer.addWidget(hint)- self._translatable.append((hint, 'msg.workdirHint'))- self.centralWidget().layout().addWidget(wrap)-- def _build_failure_box(self, outer: QVBoxLayout) -> None:- """After a known early stop of the script: what happened, the next step, and its button."""+ self.footer.setObjectName('muted')+ self.footer.setWordWrap(True)+ self.footer.setTextInteractionFlags(Qt.TextSelectableByMouse)+ act.addWidget(self.footer, 1)++ self.reveal_ipa_btn = QPushButton(f"{self.m.t('shell.showInFinder')} (IPA)")+ self.reveal_ipa_btn.clicked.connect(lambda: pu.reveal(self.m.ipa_path))+ self.reveal_ipa_btn.hide()+ act.addWidget(self.reveal_ipa_btn)++ self.reveal_arc_btn = QPushButton(f"{self.m.t('shell.showInFinder')} (romfs)")+ self.reveal_arc_btn.clicked.connect(lambda: pu.reveal(self.m.archive_path))+ self.reveal_arc_btn.hide()+ act.addWidget(self.reveal_arc_btn)++ self.reveal_app_btn = QPushButton('.app')+ self.reveal_app_btn.clicked.connect(lambda: pu.reveal(self.m.mac_app_path))+ self.reveal_app_btn.hide()+ act.addWidget(self.reveal_app_btn)++ grp.add_row(r)++ # BuildFailureCard (shown on a known early stop)self.failure_box = QFrame()- self.failure_box.setObjectName('card')- box = QVBoxLayout(self.failure_box)- box.setContentsMargins(12, 8, 12, 8)- box.setSpacing(4)- self.failure_what = QLabel('')+ self.failure_box.setObjectName('failureCard')+ self.failure_box.setContentsMargins(14, 8, 14, 14)+ fcol = QVBoxLayout(self.failure_box)+ fcol.setContentsMargins(16, 14, 16, 14)+ fcol.setSpacing(6)+ self.failure_title = QLabel()+ self.failure_title.setObjectName('sectionTitle')+ fcol.addWidget(self.failure_title)+ self.failure_what = QLabel()+ self.failure_what.setStyleSheet('font-weight: 700;')self.failure_what.setWordWrap(True)- self.failure_what.setStyleSheet(f'color: {ORANGE}; font-weight: 600;')- self.failure_next = QLabel('')+ fcol.addWidget(self.failure_what)+ self.failure_next = QLabel()+ self.failure_next.setObjectName('muted')self.failure_next.setWordWrap(True)- self.failure_next.setObjectName('note')- buttons = QHBoxLayout()- self.failure_fix_btn = QPushButton('')+ fcol.addWidget(self.failure_next)+ frow = QHBoxLayout()+ frow.setSpacing(8)+ self.failure_folder_btn = QPushButton()+ self.failure_folder_btn.clicked.connect(self._open_failure_folder)+ frow.addWidget(self.failure_folder_btn)+ self.failure_fix_btn = QPushButton()self.failure_fix_btn.clicked.connect(self._fix_failure)- self.failure_anyway_btn = QPushButton(self.m.t('fail.buildAnyway'))+ frow.addWidget(self.failure_fix_btn)+ self.failure_anyway_btn = QPushButton()+ self.failure_anyway_btn.setObjectName('danger')self.failure_anyway_btn.clicked.connect(self._build_anyway)- buttons.addWidget(self.failure_fix_btn)- buttons.addWidget(self.failure_anyway_btn)- buttons.addStretch(1)- box.addWidget(self.failure_what)- box.addWidget(self.failure_next)- box.addLayout(buttons)+ frow.addWidget(self.failure_anyway_btn)+ frow.addStretch(1)+ fcol.addLayout(frow)self.failure_box.hide()- outer.addWidget(self.failure_box)+ grp.add_row(self.failure_box)- _FIX_BUTTONS = {'translator': 'fail.translator.button', 'zbic': 'fail.zbic.button', 'iosSDK': 'fail.iosSDK.button',- 'keys': 'fail.keys.button', 'keysOld': 'fail.keys.button', 'severalGames': 'fail.showFolder', 'noTitleID': 'fail.showFolder',- 'diskFull': 'fail.showFolder'}+ return grp- def _show_failure(self) -> None:- f = self.m.failure- if f is None or self.m.running:- self.failure_box.hide()- return- self.failure_what.setText(self.m.failure_what(f))- self.failure_next.setText(self.m.t(f.next_key))- fix = self._FIX_BUTTONS.get(f.kind)- self.failure_fix_btn.setVisible(fix is not None)- if fix:- self.failure_fix_btn.setText(self.m.t(fix))- self.failure_anyway_btn.setVisible(f.flag is not None)- self.failure_anyway_btn.setText(self.m.t('fail.buildAnyway'))- self.failure_box.show()+ def _build_stages_card(self) -> CardGroup:+ grp = CardGroup(title=self.m.t('prog.title'))+ wrap = QWidget()+ self.stages_col = QVBoxLayout(wrap)+ self.stages_col.setContentsMargins(18, 12, 18, 12)+ self.stages_col.setSpacing(8)+ grp.add_row(wrap)+ grp.hide()+ return grp- def _fix_failure(self) -> None:- f = self.m.failure- if f is None:- return- if f.kind in ('keys', 'keysOld'):- self._choose_input('keys') # the same picker as the keys row- elif f.kind in ('severalGames', 'noTitleID', 'diskFull'):- folder = self.m.failure_folder(f)- if folder:- QDesktopServices.openUrl(QUrl.fromLocalFile(folder))- else:- self.m.fix_failure(f)+ def _build_log_card(self) -> CardGroup:+ grp = CardGroup(title=self.m.t('build.log'))+ head = QWidget()+ hl = QHBoxLayout(head)+ hl.setContentsMargins(18, 10, 18, 6)+ self.log_label = QLabel(self.m.t('build.log'))+ self.log_label.setObjectName('rowTitle')+ hl.addWidget(self.log_label)+ hl.addStretch(1)+ self.export_log_btn = QPushButton(self.m.t('log.export'))+ self.export_log_btn.setObjectName('ghost')+ self.export_log_btn.clicked.connect(self._export_log)+ hl.addWidget(self.export_log_btn)+ grp.add_row(head)- def _build_anyway(self) -> None:- """Asks first: the dialog states the risk. Nothing is armed until the player agrees."""- if self.m.running or not self.m.override.request(self.m.failure):- return- from PySide6.QtWidgets import QMessageBox- risk = self.m.t(f'fail.{self.m.failure.kind}.risk')- yes = QMessageBox.question(self, self.m.t('fail.confirm.title'), risk,- QMessageBox.Yes | QMessageBox.Cancel, QMessageBox.Cancel)- if yes != QMessageBox.Yes:- self.m.override.cancel()+ log_wrap = QWidget()+ lw = QVBoxLayout(log_wrap)+ lw.setContentsMargins(14, 4, 14, 14)+ self.log = QPlainTextEdit()+ self.log.setReadOnly(True)+ self.log.setPlaceholderText(self.m.t('log.placeholder'))+ self.log.setMinimumHeight(200)+ lw.addWidget(self.log)+ grp.add_row(log_wrap)+ return grp++ def _export_log(self) -> None:+ f, _ = QFileDialog.getSaveFileName(self, self.m.t('log.export'), 'nx2apple-build.log', 'Log files (*.log *.txt)')+ if f:+ try:+ Path(f).write_text(self.log.toPlainText(), encoding='utf-8')+ self._append_log(self.m.t('log.exported', f) + '\n')+ except OSError as e:+ self._append_log(self.m.t('log.exportFail', str(e)) + '\n')++ # ================================================================ Page 2: Settings++ def _build_settings_page(self) -> QWidget:+ sbody = QWidget()+ scol = QVBoxLayout(sbody)+ scol.setContentsMargins(40, 28, 40, 36)+ scol.setSpacing(22)++ self.settings_heading = CardPageHeading(self.m.t('settings.heading'), self.m.t('settings.note'))+ scol.addWidget(self.settings_heading)++ # 1. Library Card (section.library)+ self.settings_lib_group = CardGroup(title=self.m.t('section.library'))+ r_lib = QWidget()+ rl_lay = QHBoxLayout(r_lib)+ rl_lay.setContentsMargins(18, 13, 18, 13)+ rl_lay.setSpacing(12)+ self.lib_folder_dot = _dot(style.NEUTRAL_DOT)+ rl_lay.addWidget(self.lib_folder_dot)+ lcol = QVBoxLayout()+ lcol.setSpacing(2)+ self.lib_folder_title = QLabel(self.m.t('library.folderTitle'))+ self.lib_folder_title.setObjectName('rowTitle')+ self.lib_folder_path_lbl = QLabel(self.m.t('library.folderUnset'))+ self.lib_folder_path_lbl.setObjectName('mono')+ self.lib_folder_hint_lbl = QLabel(self.m.t('library.folderHint'))+ self.lib_folder_hint_lbl.setObjectName('muted')+ self.lib_folder_hint_lbl.setWordWrap(True)+ lcol.addWidget(self.lib_folder_title)+ lcol.addWidget(self.lib_folder_path_lbl)+ lcol.addWidget(self.lib_folder_hint_lbl)+ rl_lay.addLayout(lcol, 1)++ self.settings_rescan_btn = QPushButton(self.m.t('library.rescan'))+ self.settings_rescan_btn.clicked.connect(self._rescan_library)+ rl_lay.addWidget(self.settings_rescan_btn)++ self.settings_lib_choose_btn = QPushButton(self.m.t('library.chooseFolder'))+ self.settings_lib_choose_btn.setFixedWidth(184)+ self.settings_lib_choose_btn.clicked.connect(self._pick_library_folder)+ rl_lay.addWidget(self.settings_lib_choose_btn)+ self.settings_lib_group.add_row(r_lib)+ scol.addWidget(self.settings_lib_group)++ # 2. Build Tools Card (section.tools: Repo + Deps + Diagnostics)+ self.tools_group = self._build_tools_card()+ scol.addWidget(self.tools_group)++ # 3. App Card (section.app: 13-Language Dropdown + Notify + Setup Wizard + Version)+ self.app_group = self._build_app_card()+ scol.addWidget(self.app_group)++ scol.addStretch(1)+ return sbody++ def _build_tools_card(self) -> CardGroup:+ grp = CardGroup(title=self.m.t('section.tools'))++ # Row 1: Project repository+ r_repo = QWidget()+ repo_col = QVBoxLayout(r_repo)+ repo_col.setContentsMargins(18, 14, 18, 14)+ repo_col.setSpacing(8)++ r1 = QHBoxLayout()+ r1.setSpacing(10)+ self.repo_dot = _dot(style.NEUTRAL_DOT)+ r1.addWidget(self.repo_dot)+ self.repo_title = QLabel(self.m.t('repo.title'))+ self.repo_title.setObjectName('rowTitle')+ r1.addWidget(self.repo_title)+ self.repo_sub = QLabel(self.m.t('repo.note'))+ self.repo_sub.setObjectName('muted')+ r1.addWidget(self.repo_sub, 1)+ self.clone_btn = QPushButton(self.m.t('repo.download'))+ self.clone_btn.setObjectName('creamPill')+ self.clone_btn.clicked.connect(lambda: self.m.clone_repo())+ r1.addWidget(self.clone_btn)+ self.repo_btn = QPushButton(self.m.t('repo.choose'))+ self.repo_btn.clicked.connect(self._pick_repo)+ r1.addWidget(self.repo_btn)+ repo_col.addLayout(r1)++ self.repo_path_label = QLabel()+ self.repo_path_label.setObjectName('mono')+ self.repo_path_label.setWordWrap(True)+ repo_col.addWidget(self.repo_path_label)++ self.repo_hint_label = QLabel()+ self.repo_hint_label.setObjectName('muted')+ self.repo_hint_label.setWordWrap(True)+ self.repo_hint_label.setOpenExternalLinks(True)+ repo_col.addWidget(self.repo_hint_label)++ r2 = QHBoxLayout()+ r2.setSpacing(8)+ self.repo_status_label = QLabel()+ self.repo_status_label.setObjectName('muted')+ r2.addWidget(self.repo_status_label, 1)+ self.check_upd_btn = QPushButton(self.m.t('repo.update'))+ self.check_upd_btn.clicked.connect(self.m.update_repo)+ r2.addWidget(self.check_upd_btn)+ repo_col.addLayout(r2)+ grp.add_row(r_repo)+ grp.add_divider()++ # Row 2: Device dependencies+ r_deps = QWidget()+ deps_col = QVBoxLayout(r_deps)+ deps_col.setContentsMargins(18, 14, 18, 14)+ deps_col.setSpacing(10)++ dh = QHBoxLayout()+ dh.setSpacing(10)+ self.deps_dot = _dot(style.NEUTRAL_DOT)+ dh.addWidget(self.deps_dot)+ self.deps_title = QLabel(self.m.t('dep.title'))+ self.deps_title.setObjectName('rowTitle')+ dh.addWidget(self.deps_title)+ self.deps_summary = QLabel(self.m.t('dep.checking'))+ self.deps_summary.setObjectName('muted')+ dh.addWidget(self.deps_summary, 1)+ self.install_all_btn = QPushButton(self.m.t('dep.installAll'))+ self.install_all_btn.setObjectName('creamPill')+ self.install_all_btn.clicked.connect(self.m.install_all_missing)+ dh.addWidget(self.install_all_btn)+ self.recheck_btn = QPushButton(self.m.t('dep.recheck'))+ self.recheck_btn.clicked.connect(self.m.check_deps)+ dh.addWidget(self.recheck_btn)+ self.deps_toggle_btn = QPushButton(self.m.t('dep.hide'))+ self.deps_toggle_btn.setObjectName('ghost')+ self.deps_toggle_btn.clicked.connect(self._toggle_deps_expanded)+ dh.addWidget(self.deps_toggle_btn)+ deps_col.addLayout(dh)++ self.deps_rows_host = QWidget()+ self.deps_rows = QVBoxLayout(self.deps_rows_host)+ self.deps_rows.setContentsMargins(0, 4, 0, 0)+ self.deps_rows.setSpacing(8)+ deps_col.addWidget(self.deps_rows_host)+ grp.add_row(r_deps)+ grp.add_divider()++ # Row 2.5: Shell Cache Folder (mirrors ShellCacheRow.swift)+ r_cache = QWidget()+ rc_lay = QHBoxLayout(r_cache)+ rc_lay.setContentsMargins(18, 12, 18, 12)+ rc_lay.setSpacing(12)+ self.cache_dot = _dot(style.GREEN)+ rc_lay.addWidget(self.cache_dot)+ ccol = QVBoxLayout()+ ccol.setSpacing(2)+ self.cache_title_lbl = QLabel(self.m.t('shellCache.row'))+ self.cache_title_lbl.setObjectName('rowTitle')+ self.cache_path_lbl = QLabel(self.m.shell_cache_path)+ self.cache_path_lbl.setObjectName('mono')+ self.cache_path_lbl.setWordWrap(True)+ self.cache_note_lbl = QLabel(self.m.t('shellCache.note'))+ self.cache_note_lbl.setObjectName('muted')+ self.cache_note_lbl.setWordWrap(True)+ self.cache_status_lbl = QLabel('')+ self.cache_status_lbl.setObjectName('muted')+ self.cache_status_lbl.setWordWrap(True)+ self.cache_status_lbl.hide()+ ccol.addWidget(self.cache_title_lbl)+ ccol.addWidget(self.cache_path_lbl)+ ccol.addWidget(self.cache_note_lbl)+ ccol.addWidget(self.cache_status_lbl)+ rc_lay.addLayout(ccol, 1)++ self.cache_open_btn = QPushButton(self.m.t('shellCache.open'))+ self.cache_open_btn.clicked.connect(self._open_shell_cache)+ rc_lay.addWidget(self.cache_open_btn)++ self.cache_move_btn = QPushButton(self.m.t('shellCache.move'))+ self.cache_move_btn.clicked.connect(self._move_shell_cache)+ rc_lay.addWidget(self.cache_move_btn)++ self.cache_default_btn = QPushButton(self.m.t('shellCache.useDefault'))+ self.cache_default_btn.clicked.connect(self._reset_shell_cache)+ self.cache_default_btn.setVisible(not self.m.shell_cache_is_default)+ rc_lay.addWidget(self.cache_default_btn)+ grp.add_row(r_cache)+ grp.add_divider()++ # Row 3: Copy Diagnostics (diag.title / diag.copy)+ r_diag = QWidget()+ rd_lay = QHBoxLayout(r_diag)+ rd_lay.setContentsMargins(18, 12, 18, 12)+ rd_lay.setSpacing(12)+ rd_lay.addWidget(_dot(style.GREEN))+ dcol = QVBoxLayout()+ dcol.setSpacing(2)+ self.diag_title_lbl = QLabel(self.m.t('diag.title'))+ self.diag_title_lbl.setObjectName('rowTitle')+ self.diag_note_lbl = QLabel(self.m.t('diag.note'))+ self.diag_note_lbl.setObjectName('muted')+ self.diag_note_lbl.setWordWrap(True)+ dcol.addWidget(self.diag_title_lbl)+ dcol.addWidget(self.diag_note_lbl)+ rd_lay.addLayout(dcol, 1)+ self.diag_btn = QPushButton(self.m.t('diag.copy'))+ self.diag_btn.setFixedWidth(184)+ self.diag_btn.clicked.connect(self._copy_diagnostics)+ rd_lay.addWidget(self.diag_btn)+ grp.add_row(r_diag)++ return grp++ def _open_shell_cache(self) -> None:+ p = Path(self.m.shell_cache_path)+ try:+ p.mkdir(parents=True, exist_ok=True)+ except OSError:+ pass+ pu.reveal(str(p))++ def _move_shell_cache(self) -> None:+ d = QFileDialog.getExistingDirectory(+ self,+ self.m.t('shellCache.pickMessage'),+ str(Path(self.m.shell_cache_path).parent),+ )+ if not d:return- if self.m.override.confirm():- self._build_clicked()+ ok, msg = self.m.move_shell_cache(d)+ self.cache_status_lbl.setText(msg)+ self.cache_status_lbl.setStyleSheet(+ f'color: {style.GREEN if ok else style.AMBER}; font-size: 12px;'+ )+ self.cache_status_lbl.show()+ self._refresh_all()++ def _reset_shell_cache(self) -> None:+ ok, msg = self.m.reset_shell_cache_default()+ self.cache_status_lbl.setText(msg)+ self.cache_status_lbl.setStyleSheet(+ f'color: {style.GREEN if ok else style.AMBER}; font-size: 12px;'+ )+ self.cache_status_lbl.show()+ self._refresh_all()- @staticmethod- def _separator() -> QFrame:- line = QFrame()- line.setFrameShape(QFrame.HLine)- line.setStyleSheet(f'color: {CARD_EDGE};')- return line+ def _copy_diagnostics(self) -> None:+ report = feat.Diagnostics.format_report(+ app_version=APP_VERSION,+ repo_path=self.m.repo_path,+ deps=self.m.deps,+ last_log=self.log.toPlainText(),+ )+ cb = QApplication.clipboard()+ if cb:+ cb.setText(report)+ self.diag_btn.setText(self.m.t('diag.copied'))+ QTimer.singleShot(2000, lambda: self.diag_btn.setText(self.m.t('diag.copy')))- # ---------------------------------------------------------------- refresh+ def _toggle_deps_expanded(self) -> None:+ self._deps_expanded = not self._deps_expanded+ self.deps_rows_host.setVisible(self._deps_expanded)+ self.deps_toggle_btn.setText(self.m.t('dep.hide' if self._deps_expanded else 'dep.show'))++ def _build_app_card(self) -> CardGroup:+ grp = CardGroup(title=self.m.t('section.app'))++ # Row 1: Language 13-language dropdown+ r_lang = QWidget()+ rl_lay = QHBoxLayout(r_lang)+ rl_lay.setContentsMargins(18, 12, 18, 12)+ rl_lay.addWidget(_dot(style.GREEN))+ self.app_lang_lbl = QLabel(self.m.t('settings.language'))+ self.app_lang_lbl.setObjectName('rowTitle')+ rl_lay.addWidget(self.app_lang_lbl, 1)++ self.lang_combo = QComboBox()+ self.lang_combo.setObjectName('launcherDropdown')+ self.lang_combo.setFixedWidth(184)+ for lg in Lang.all():+ self.lang_combo.addItem(lg.name, lg.code)+ curr_idx = next((i for i, lg in enumerate(Lang.all()) if lg.code == self.m.lang.code), 0)+ self.lang_combo.setCurrentIndex(curr_idx)+ self.lang_combo.currentIndexChanged.connect(self._on_lang_combo_changed)+ rl_lay.addWidget(self.lang_combo)+ grp.add_row(r_lang)+ grp.add_divider()++ # Row 2: Notify when a build ends+ r_notif = QWidget()+ rn_lay = QHBoxLayout(r_notif)+ rn_lay.setContentsMargins(18, 12, 18, 12)+ rn_lay.addWidget(_dot(style.NEUTRAL_DOT))+ ncol = QVBoxLayout()+ ncol.setSpacing(2)+ self.notif_title_lbl = QLabel(self.m.t('settings.notify'))+ self.notif_title_lbl.setObjectName('rowTitle')+ self.notif_note_lbl = QLabel(self.m.t('settings.notifyNote'))+ self.notif_note_lbl.setObjectName('muted')+ self.notif_note_lbl.setWordWrap(True)+ ncol.addWidget(self.notif_title_lbl)+ ncol.addWidget(self.notif_note_lbl)+ rn_lay.addLayout(ncol, 1)+ notif_on = self.m.settings_value('notifyOnComplete', True)+ self.notif_switch = LauncherSwitch(bool(notif_on))+ self.notif_switch.toggled.connect(lambda v: self.m.settings_set('notifyOnComplete', v))+ rn_lay.addWidget(self.notif_switch)+ grp.add_row(r_notif)+ grp.add_divider()++ # Row 3: Run setup again (OnboardingDialog)+ r_setup = QWidget()+ rs_lay = QHBoxLayout(r_setup)+ rs_lay.setContentsMargins(18, 12, 18, 12)+ rs_lay.addWidget(_dot(style.NEUTRAL_DOT))+ scol = QVBoxLayout()+ scol.setSpacing(2)+ self.setup_row_title = QLabel(self.m.t('settings.setup'))+ self.setup_row_title.setObjectName('rowTitle')+ self.setup_row_note = QLabel(self.m.t('settings.setupNote'))+ self.setup_row_note.setObjectName('muted')+ self.setup_row_note.setWordWrap(True)+ scol.addWidget(self.setup_row_title)+ scol.addWidget(self.setup_row_note)+ rs_lay.addLayout(scol, 1)+ self.run_onboarding_btn = QPushButton(self.m.t('settings.setupBtn'))+ self.run_onboarding_btn.setFixedWidth(184)+ self.run_onboarding_btn.clicked.connect(self._open_onboarding)+ rs_lay.addWidget(self.run_onboarding_btn)+ grp.add_row(r_setup)+ grp.add_divider()++ # Row 4: App Version+ r_ver = QWidget()+ rv_lay = QHBoxLayout(r_ver)+ rv_lay.setContentsMargins(18, 12, 18, 12)+ rv_lay.addWidget(_dot(style.GREEN))+ self.ver_title_lbl = QLabel(self.m.t('app.version', APP_VERSION))+ self.ver_title_lbl.setObjectName('rowTitle')+ rv_lay.addWidget(self.ver_title_lbl, 1)+ self.ver_status_lbl = QLabel(self.m.t('app.upToDate'))+ self.ver_status_lbl.setObjectName('muted')+ rv_lay.addWidget(self.ver_status_lbl)+ grp.add_row(r_ver)++ return grp++ def _on_lang_combo_changed(self, idx: int) -> None:+ code = self.lang_combo.itemData(idx)+ if code and code != self.m.lang.code:+ self.m.set_lang(Lang(str(code)))++ def _open_onboarding(self) -> None:+ OnboardingDialog(self.m, self).exec()+ self._refresh_all()++ # ================================================================ Bottom Activity Bar++ def _build_activity_bar(self) -> QFrame:+ bar = QFrame()+ bar.setObjectName('activityBar')+ bar.setFixedHeight(44)+ row = QHBoxLayout(bar)+ row.setContentsMargins(28, 0, 28, 0)+ row.setSpacing(12)++ self.act_dot = StatusDot(style.NEUTRAL_DOT, size=7)+ row.addWidget(self.act_dot)++ self.act_title = QLabel(self.m.t('library.localNote'))+ self.act_title.setStyleSheet('font-size: 12px; font-weight: 600;')+ row.addWidget(self.act_title)++ self.act_detail = QLabel('')+ self.act_detail.setObjectName('muted')+ row.addWidget(self.act_detail, 1)++ self.act_progress = QProgressBar()+ self.act_progress.setRange(0, 100)+ self.act_progress.setTextVisible(False)+ self.act_progress.setFixedWidth(160)+ self.act_progress.hide()+ row.addWidget(self.act_progress)++ self.act_view_btn = QPushButton(self.m.t('library.viewBuild'))+ self.act_view_btn.setObjectName('ghost')+ self.act_view_btn.clicked.connect(lambda: self._switch_page('builds'))+ self.act_view_btn.hide()+ row.addWidget(self.act_view_btn)++ self.act_stop_btn = QPushButton(self.m.t('btn.stop'))+ self.act_stop_btn.setObjectName('danger')+ self.act_stop_btn.clicked.connect(self.m.cancel_build)+ self.act_stop_btn.hide()+ row.addWidget(self.act_stop_btn)++ return bar++ def _refresh_activity_bar(self) -> None:+ if self.m.running:+ self.act_dot.set_color(style.AMBER)+ self.act_title.setText(self.m.t('activity.ios' if self.m.target == 'ios' else 'activity.mac'))+ curr_stage = next((s for s in self.m.stages if s.state == 'running'), None)+ done_cnt = sum(1 for s in self.m.stages if s.state == 'done')+ total_cnt = max(7, len(self.m.stages))+ pct = int(min(95, (done_cnt * 100) // total_cnt))+ self.act_detail.setText(f"{curr_stage.name}: {curr_stage.detail}" if curr_stage else '')+ self.act_progress.setValue(pct)+ self.act_progress.show()+ self.act_view_btn.setText(self.m.t('library.viewBuild'))+ self.act_view_btn.setVisible(self._current_page != 'builds')+ self.act_stop_btn.setText(self.m.t('btn.stop'))+ self.act_stop_btn.show()+ else:+ self.act_dot.set_color(style.GREEN if self.m.can_build else style.NEUTRAL_DOT)+ self.act_title.setText(self.m.t('library.localNote'))+ self.act_detail.setText(self.footer.text())+ self.act_progress.hide()+ self.act_view_btn.hide()+ self.act_stop_btn.hide()++ # ================================================================ Refresh Logicdef _refresh_all(self) -> None:+ t = self.m.tself.lang_btn.setText(self.m.lang.toggle_label)- # everything built once at start-up re-reads its string here: the language toggle emits- # repoChanged, and without this the card titles, the notes and the buttons kept their- # start-up language — the report's half-Chinese interface- for w, key in self._translatable:- w.setText(self.m.t(key))++ # Sync language dropdown without re-triggering signal+ self.lang_combo.blockSignals(True)+ curr_idx = next((i for i, lg in enumerate(Lang.all()) if lg.code == self.m.lang.code), 0)+ self.lang_combo.setCurrentIndex(curr_idx)+ self.lang_combo.blockSignals(False)++ # Navigation bar texts+ for pid, btn in self.nav_btns.items():+ btn.setText(t('nav.' + pid))+ self.search_input.setPlaceholderText(t('library.search'))+ self.new_build_btn.setText('+ ' + t('library.newBuild'))++ # Headings & Cards+ self.build_heading.set_text(t('build.heading'), t('build.intro'))+ self.files_group.set_title(t('section.files'))+ self.files_group.set_footer(t('msg.workdirHint'))+ self.folder_cta_title.setText(t('build.folderCTA') + ' · ' + t('data.note'))+ self.folder_cta_sub.setText(t('build.folderNote') + ' (' + t('data.folderHint') + ')')+ self.pick_folder_btn.setText(t('data.pickFolder'))+ arrow = '▾' if self._options_expanded else '▸'+ self.opt_toggle_btn.setText(f"{arrow} {t('build.options').replace('&', '&&')}")+ self.out_title_lbl.setText(t('build.saveTo'))+ self.out_btn.setText(t('build.outDir'))+ self.out_clear_btn.setText(t('data.clear'))++ self.target_group.set_title(t('section.target'))+ self.bc_title_lbl.setText(t('opt.bc'))+ self.bc_note_lbl.setText(t('opt.bc.note'))++ self.stages_card.set_title(t('prog.title'))+ self.log_group.set_title(t('build.log'))+ self.log_label.setText(t('build.log'))+ self.export_log_btn.setText(t('log.export'))+ self.log.setPlaceholderText(t('log.placeholder'))++ # Settings page texts+ self.settings_heading.set_text(t('settings.heading'), t('settings.note'))+ self.settings_lib_group.set_title(t('section.library'))+ self.lib_folder_title.setText(t('library.folderTitle'))+ self.lib_folder_path_lbl.setText(self.m.library.games_folder or t('library.folderUnset'))+ self.lib_folder_hint_lbl.setText(t('library.folderHint'))+ _set_dot(self.lib_folder_dot, style.GREEN if self.m.library.games_folder else style.NEUTRAL_DOT)+ self.settings_rescan_btn.setText(t('library.rescan'))+ self.settings_lib_choose_btn.setText(t('library.chooseFolder'))++ self.tools_group.set_title(t('section.tools'))+ self.repo_title.setText(t('repo.title'))+ self.repo_sub.setText(t('repo.note'))+ self.clone_btn.setText(t('repo.download'))+ self.repo_btn.setText(t('repo.choose'))+ self.check_upd_btn.setText(t('repo.update'))+ self.deps_title.setText(t('dep.title'))+ self.recheck_btn.setText(t('dep.recheck'))+ self.deps_toggle_btn.setText(t('dep.hide' if self._deps_expanded else 'dep.show'))+ self.install_all_btn.setText(t('dep.installAll'))+ self.cache_title_lbl.setText(t('shellCache.row'))+ self.cache_path_lbl.setText(self.m.shell_cache_path)+ self.cache_note_lbl.setText(t('shellCache.note'))+ self.cache_open_btn.setText(t('shellCache.open'))+ self.cache_move_btn.setText(t('shellCache.move'))+ self.cache_default_btn.setText(t('shellCache.useDefault'))+ self.cache_default_btn.setVisible(not self.m.shell_cache_is_default)+ self.diag_title_lbl.setText(t('diag.title'))+ self.diag_note_lbl.setText(t('diag.note'))+ self.diag_btn.setText(t('diag.copy'))+ self.reveal_ipa_btn.setText(f"{t('shell.showInFinder')} (IPA)")+ self.reveal_arc_btn.setText(f"{t('shell.showInFinder')} (romfs)")+ self.top_bar.recenter_nav()++ self.app_group.set_title(t('section.app'))+ self.app_lang_lbl.setText(t('settings.language'))+ self.notif_title_lbl.setText(t('settings.notify'))+ self.notif_note_lbl.setText(t('settings.notifyNote'))+ self.setup_row_title.setText(t('settings.setup'))+ self.setup_row_note.setText(t('settings.setupNote'))+ self.run_onboarding_btn.setText(t('settings.setupBtn'))+ self.ver_title_lbl.setText(t('app.version', APP_VERSION))+ self.ver_status_lbl.setText(t('app.upToDate'))++ self._refresh_engine_banner()+ self._refresh_repo()+ self._refresh_deps()+ self._refresh_inputs()+ self._refresh_target()+ self._refresh_install_card()+ self._refresh_stages()+ self._refresh_running()self._show_failure()- self._show_engine_sync()- full = (pu.short_path(self.m.repo_path) if self.m.repo_ok- else (self.m.repo_path or self.m.t('repo.notFound')))- self.repo_path_label.setText(full)- self.repo_path_label.setToolTip(full) # the full path on hover when elided- if self.m.repo_ok:- self.repo_dot.setStyleSheet(f'color: {GREEN};')- self.repo_status.setText(self.m.repo_status or- (self.m.t('repo.ok') if self.m.repo_is_git else self.m.t('repo.noGit')))+ self._refresh_library()+ self._refresh_activity_bar()++ def _refresh_repo(self) -> None:+ t = self.m.t+ ok = self.m.repo_ok+ busy = self.m.repo_busy+ _set_dot(self.repo_dot, style.GREEN if ok else style.RED)+ self.repo_path_label.setText(self.m.repo_path if ok else t('repo.notFound'))+ self.clone_btn.setVisible(not ok)+ self.clone_btn.setEnabled(not busy and not self.m.running)+ self.repo_btn.setEnabled(not busy and not self.m.running)+ if not ok:+ url = 'https://github.com/LNPANDY/NX2Apple'+ self.repo_hint_label.setText(+ f'{t("repo.firstHint")}<br>{t("repo.manualHint")} '+ f'<a href="{url}" style="color:{style.ACCENT};">{url}</a>{t("repo.manualHint2")}'+ )+ self.repo_hint_label.show()else:- self.repo_dot.setStyleSheet(f'color: {RED};')- self.repo_status.setText(self.m.repo_status or self.m.t('repo.firstHint'))- # Download when there is no usable checkout; one update button when there is a git one.- self.download_btn.setVisible(not self.m.repo_ok)- self.update_btn.setVisible(self.m.repo_ok and self.m.repo_is_git)- busy = self.m.repo_busy or self.m.running- for b in (self.download_btn, self.update_btn, self.choose_btn):- b.setEnabled(not busy)- self.engine_retry_btn.setEnabled(not self.m.engine_syncing)- if getattr(self.m, 'log_path', None):- self.log_path_label.setText(self.m.t('log.at', str(self.m.log_path)))- self._refresh_inputs()- self._refresh_deps()+ self.repo_hint_label.hide()+ is_git = self.m.repo_is_git+ self.check_upd_btn.setVisible(is_git)+ self.check_upd_btn.setEnabled(not busy and not self.m.running)+ self.repo_status_label.setText(self.m.repo_status or (t('repo.ok') if ok else ''))+ self.repo_status_label.setVisible(bool(self.m.repo_status or ok))++ def _refresh_deps(self) -> None:+ t = self.m.t+ while self.deps_rows.count():+ item = self.deps_rows.takeAt(0)+ if item.widget():+ item.widget().deleteLater()++ if not self.m.deps_checked:+ _set_dot(self.deps_dot, style.NEUTRAL_DOT)+ self.deps_summary.setText(t('dep.checking'))+ self.install_all_btn.hide()+ self._refresh_running()+ return+ if not self.m.deps:+ _set_dot(self.deps_dot, style.RED)+ self.deps_summary.setText(t('dep.checkFailed'))+ self.install_all_btn.hide()+ self._refresh_running()+ return++ req_missing = sum(1 for d in self.m.deps if not d.ok and d.required)+ opt_missing = sum(1 for d in self.m.deps if not d.ok and not d.required)+ fixable = any(not d.ok and d.install for d in self.m.deps)+ any_busy = any(d.installing for d in self.m.deps)+ if req_missing == 0 and opt_missing == 0:+ _set_dot(self.deps_dot, style.GREEN)+ self.deps_summary.setText(t('dep.allReady'))+ elif req_missing == 0:+ _set_dot(self.deps_dot, style.GREEN)+ self.deps_summary.setText(t('dep.onlyOptional', opt_missing))+ elif opt_missing:+ _set_dot(self.deps_dot, style.AMBER)+ self.deps_summary.setText(t('dep.missingOptional', req_missing, opt_missing))+ else:+ _set_dot(self.deps_dot, style.AMBER)+ self.deps_summary.setText(t('dep.missing', req_missing))+ self.install_all_btn.setVisible(fixable)+ self.install_all_btn.setEnabled(not any_busy)++ for d in self.m.deps:+ self.deps_rows.addWidget(self._make_dep_row(d))++ self._refresh_running()++ def _make_dep_row(self, d: Dep) -> QFrame:+ t = self.m.t+ f = QFrame()+ f.setObjectName('subcard')+ outer = QVBoxLayout(f)+ outer.setContentsMargins(12, 10, 12, 10)+ outer.setSpacing(6)++ r = QHBoxLayout()+ r.setSpacing(10)+ color = style.GREEN if d.ok else (style.NEUTRAL_DOT if not d.required else+ (style.AMBER if d.state is DepState.OLD else style.RED))+ r.addWidget(_dot(color))+ col = QVBoxLayout()+ col.setSpacing(2)+ title = QLabel(t(d.title_key))+ title.setStyleSheet('font-weight: 600;')+ detail = self._format_dep_detail(d)+ sub = QLabel(detail or t(d.hint_key))+ sub.setObjectName('mono' if d.ok else 'muted')+ sub.setWordWrap(True)+ sub.setOpenExternalLinks(True)+ col.addWidget(title)+ col.addWidget(sub)+ r.addLayout(col, 1)++ if d.install and (not d.ok or d.id == 'ios_sdk'):+ b = QPushButton(t('dep.installing') if d.installing else t('dep.install'))+ b.setEnabled(not d.installing)+ b.clicked.connect(lambda _=False, dep=d: self.m.install_dep(dep))+ r.addWidget(b)+ elif not d.ok and d.id == 'xcode':+ b = QPushButton(t('dep.openAppStore'))+ b.clicked.connect(lambda: QDesktopServices.openUrl(+ QUrl('macappstore://apps.apple.com/app/id497799835')))+ r.addWidget(b)+ if d.pick_key:+ label_key = 'dep.pick.metal' if d.pick_key == 'metal_dir' else 'dep.pick'+ pb = QPushButton(t(label_key))+ pb.setEnabled(not d.installing)+ pb.clicked.connect(lambda _=False, dep=d: self.m.pick_dep_folder(dep))+ r.addWidget(pb)+ outer.addLayout(r)++ guide_key = {'ios_sdk': 'dep.guide.iossdk', 'metal': 'dep.guide.metal'}.get(d.id)+ if not d.ok and guide_key:+ guide = QLabel(t(guide_key))+ guide.setObjectName('muted')+ guide.setWordWrap(True)+ guide.setOpenExternalLinks(True)+ guide.setContentsMargins(18, 2, 4, 0)+ outer.addWidget(guide)++ if not d.ok and (d.last_error or d.fix_hint):+ msg = (d.last_error + ' — ' if d.last_error else '') + (t(d.fix_hint) if d.fix_hint else '')+ err = QLabel(msg)+ err.setWordWrap(True)+ err.setStyleSheet(f'color: {style.AMBER}; font-size: 11px;')+ err.setContentsMargins(18, 2, 4, 0)+ outer.addWidget(err)+ return f++ def _format_dep_detail(self, d: Dep) -> str:+ if d.detail == 'dep.xcode.noSDK':+ return self.m.t('dep.xcode.noSDK')+ if d.detail.startswith('dep.python.old:'):+ ver = d.detail.split(':', 1)[1]+ return self.m.t('dep.python.old', ver, f'{pu.MIN_PYTHON[0]}.{pu.MIN_PYTHON[1]}')+ if d.detail.startswith('dep.python.missing:'):+ py = d.detail.split(':', 1)[1]+ return self.m.t('dep.python.missing', py)+ if d.detail.startswith('dep.python.notFound:'):+ need = d.detail.split(':', 1)[1]+ return self.m.t('dep.python.notFound', need, need)+ if d.detail.startswith('dep.python.none:'):+ found = d.detail.split(':', 1)[1]+ return self.m.t('dep.python.none', found)+ if d.detail.startswith('dep.metal.other:'):+ _, got, tested = d.detail.split(':', 2)+ return self.m.t('dep.metal.other', got, tested)+ return d.detaildef _refresh_inputs(self) -> None:- self.folder_label.setText(pu.short_path(self.m.game_dir) if self.m.game_dir- else self.m.t('data.folderHint'))- vals = {'base': self.m.base_path, 'update': self.m.update_path, 'keys': self.m.keys_path}- for key, (dot, val) in self.input_rows.items():+ t = self.m.t+ folder = self.m.game_folder+ problem = self.m.game_folder_problem+ values = {+ 'base': self.m.base_path,+ 'update': self.m.update_path,+ 'dlc': (t('data.files', len(self.m.dlc_paths)) ++ ', '.join(Path(p).name for p in self.m.dlc_paths)) if self.m.dlc_paths else '',+ 'keys': self.m.keys_path,+ }+ empty_label = {+ 'base': t('data.notSelected'),+ 'update': t('data.notSelectedOptional'),+ 'dlc': t('data.notSelectedDlc'),+ 'keys': t('data.notSelected'),+ }++ _set_dot(self.folder_cta_dot, style.GREEN if (folder or self.m.base_path) else style.NEUTRAL_DOT)++ for key, widgets in self.input_rows.items():+ widgets['title'].setText(t(widgets['title_key']))+ widgets['clear'].setText(t('data.clear'))folder_text = self.m.input_row_text(key)- if folder_text is not None: # a game folder or a NUP: what it holds, and no keys needed- dot.setText('●')- dot.setStyleSheet(f'color: {GREEN};')- val.setText(folder_text)- val.setStyleSheet(f'color: {MUTED};')- continue- if key == 'base' and self.m.game_folder_problem: # refused: the reason, on the base row- dot.setText('✕')- dot.setStyleSheet(f'color: {RED};')- val.setText(self.m.game_folder_problem)- val.setStyleSheet(f'color: {ORANGE};')- continue- if key == 'dlc':- n = len(self.m.dlc_paths)- text = (Path(self.m.dlc_paths[0]).name + (f' +{n - 1}' if n > 1 else '')) if n else ''- set_, optional = bool(n), True+ if problem and key == 'base':+ widgets['path'].setText(problem)+ widgets['path'].setObjectName('muted')+ _set_dot(widgets['dot'], style.RED)+ widgets['clear'].setVisible(True)+ widgets['choose'].setText(t('data.choose'))+ widgets['choose'].setVisible(True)+ elif folder is not None and folder_text is not None:+ has_val = key == 'base' or (key == 'update' and folder.newest_update is not None) or (key == 'dlc' and bool(folder.dlc))+ widgets['path'].setText(folder_text)+ widgets['path'].setObjectName('mono' if has_val else 'muted')+ _set_dot(widgets['dot'], style.GREEN if has_val else style.NEUTRAL_DOT)+ widgets['clear'].setVisible(key == 'base')+ widgets['choose'].setVisible(False)else:- v = vals.get(key, '')- text, set_, optional = (Path(v).name if v else ''), bool(v), key == 'update'- if set_:- dot.setText('●')- dot.setStyleSheet(f'color: {GREEN};')- val.setText(text)- val.setStyleSheet(f'color: {MUTED};')- else:- dot.setText('○' if optional else '✕')- dot.setStyleSheet(f'color: {MUTED if optional else RED};')- val.setText(self.m.t('data.notSelectedOptional') if optional else self.m.t('data.notSelected'))- val.setStyleSheet(f'color: {MUTED if optional else ORANGE};')- self._refresh_running()-- @staticmethod- def _esc(text: str) -> str:- # The failure line is tool output; keep it out of the rich-text parser.- return (text.replace('&', '&').replace('<', '<').replace('>', '>'))+ v = values[key]+ widgets['path'].setText(v if v else empty_label[key])+ widgets['path'].setObjectName('mono' if v else 'muted')+ _set_dot(widgets['dot'],+ style.GREEN if v else (style.AMBER if widgets['req'] else style.NEUTRAL_DOT))+ widgets['clear'].setVisible(bool(v))+ widgets['choose'].setText(t('data.change') if v else t('data.choose'))+ widgets['choose'].setVisible(True)+ widgets['path'].style().unpolish(widgets['path'])+ widgets['path'].style().polish(widgets['path'])- def _refresh_deps(self) -> None:- while self.deps_container.count():- item = self.deps_container.takeAt(0)- if w := item.widget():- w.deleteLater()- for d in self.m.deps:- row = QWidget()- h = QHBoxLayout(row)- h.setContentsMargins(0, 0, 0, 0)- h.setSpacing(6)- # An optional tool that is missing reads as a muted ○, not a red ✕: it does not block- # the build in front of the player, and the red row made a complete Metal toolchain look- # broken (the report's screenshot: spirv-cross and glslangValidator, both OpenGL-only).- optional_missing = not d.ok and not getattr(d, 'required', True)- mark = QLabel('●' if d.ok else ('◐' if d.state is DepState.OLD else ('○' if optional_missing else '✕')))- mark.setFixedWidth(14)- mark.setStyleSheet(f'color: {GREEN if d.ok else (MUTED if optional_missing else (ORANGE if d.state is DepState.OLD else RED))};')- h.addWidget(mark)- name = QLabel(self.m.t(d.title_key))- name.setFixedWidth(140)- h.addWidget(name)- detail = d.detail- if detail.startswith('dep.'):- if ':' in detail:- key, arg = detail.split(':', 1)- detail = self.m.t(key, arg)- else:- detail = self.m.t(detail)- elif detail:- detail = pu.short_path(detail)- # A long detail (the link probe's three-attempt report) would be elided to nothing on- # one line: it moves into its own wrapped block under the row, where it is readable.- if len(detail) > 140 or '\n' in detail:- head = QLabel(detail[:120] + '…')- head.setObjectName('mono')- head.setTextInteractionFlags(Qt.TextSelectableByMouse)- h.addWidget(head, 1)- note = QLabel(detail)- note.setObjectName('mono')- note.setWordWrap(True)- note.setTextInteractionFlags(Qt.TextSelectableByMouse)- note.setContentsMargins(20, 0, 0, 4)- self.deps_container.addWidget(row)- self.deps_container.addWidget(note)- continue- lab = QLabel(detail)- lab.setObjectName('mono')- lab.setTextInteractionFlags(Qt.TextSelectableByMouse)- lab.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Preferred)- lab.setToolTip(detail)- h.addWidget(lab, 1)- if not d.ok:- if d.install:- btn = QPushButton(self.m.t('dep.install'))- btn.setEnabled(not d.installing)- btn.clicked.connect(lambda _=False, dep=d: self.m.install_dep(dep))- h.addWidget(btn)- if d.pick_key:- # Apple-licensed pieces cannot be downloaded by the app: Choose points at a- # copy the user already has — an unpacked folder, or (Metal) the downloaded- # zip, which the app unpacks and remembers.- pick = QPushButton(self.m.t('dep.pick.metal' if d.pick_key == 'metal_dir' else 'dep.pick'))- pick.clicked.connect(lambda _=False, dep=d: self.m.pick_dep_folder(dep))- h.addWidget(pick)- if not d.install and not d.pick_key:- hint = QLabel(self.m.t(d.hint_key))- hint.setObjectName('note')- hint.setOpenExternalLinks(True) # the Windows hints carry download links- h.addWidget(hint)- self.deps_container.addWidget(row)- # Why the last install failed and what to do: the tool's own line under the row, the- # fix under it (Mac parity). Cleared when the row installs successfully.- if not d.ok and (d.last_error or d.fix_hint):- note = QLabel(('<br>' if d.last_error and d.fix_hint else '')- + (self._esc(d.last_error) if d.last_error else '')- + ('<br>' + self.m.t(d.fix_hint) if d.fix_hint else ''))- note.setObjectName('note')- note.setOpenExternalLinks(True)- note.setContentsMargins(20, 0, 0, 4)- self.deps_container.addWidget(note)- for d in self.m.deps:- if not d.ok and not d.install and d.id == 'ios_sdk':- guide = QLabel(self.m.t('dep.guide.iossdk'))- guide.setObjectName('note')- guide.setOpenExternalLinks(True)- guide.setContentsMargins(20, 0, 0, 4)- self.deps_container.addWidget(guide)- elif not d.ok and not d.install and d.id == 'metal':- guide = QLabel(self.m.t('dep.guide.metal'))- guide.setObjectName('note')- guide.setOpenExternalLinks(True)- guide.setContentsMargins(20, 0, 0, 4)- self.deps_container.addWidget(guide)- if self.m.deps_checked:- if not self.m.deps:- # The check produced no rows at all, which means it failed — never report that as- # "all ready" (see Model.all_deps_ok) or as "0 missing".- self.deps_summary.setText('⚠ ' + self.m.t('dep.checkFailed'))- self.deps_summary.setStyleSheet(f'color: {RED}; font-weight: 600;')- elif self.m.all_deps_ok:- self.deps_summary.setText('● ' + self.m.t('dep.allReady'))- self.deps_summary.setStyleSheet(f'color: {GREEN}; font-weight: 600;')+ # Live KeyCheck status when both base and keys are selected+ if folder is None and self.m.base_path and self.m.keys_path and os.path.isfile(self.m.base_path) and os.path.isfile(self.m.keys_path):+ verdict = feat.KeyCheck.check(+ self.m.keys_path,+ self.m.base_path,+ self.m.update_path,+ self.m.dlc_paths,+ )+ if verdict.kind == 'fits':+ _set_dot(self.keycheck_dot, style.GREEN)+ self.keycheck_lbl.setText(t('keycheck.fits'))+ elif verdict.kind == 'unreadableKeys':+ _set_dot(self.keycheck_dot, style.RED)+ self.keycheck_lbl.setText(t('keycheck.unreadable'))+ elif verdict.kind == 'missingHeaderKey':+ _set_dot(self.keycheck_dot, style.RED)+ self.keycheck_lbl.setText(t('keycheck.noHeaderKey'))+ elif verdict.kind == 'wrongHeaderKey':+ _set_dot(self.keycheck_dot, style.RED)+ part_name = t('keycheck.part.' + (verdict.part or 'base'))+ self.keycheck_lbl.setText(t('keycheck.wrongHeaderKey', part_name))+ elif verdict.kind == 'missingKey':+ _set_dot(self.keycheck_dot, style.AMBER)+ part_name = t('keycheck.part.' + (verdict.part or 'base'))+ msg = t('keycheck.tooOld', part_name, verdict.key)+ if verdict.firmware:+ msg += ' ' + t('keycheck.firmware', verdict.firmware)+ self.keycheck_lbl.setText(msg)else:- # Required only: an optional tool (glslangValidator for OpenGL games) or one that- # only some titles need (spirv-cross) was counted here, so a machine that could- # build the game in front of it read "缺 3 项" and looked broken.- n = sum(1 for d in self.m.deps if not d.ok and getattr(d, 'required', True))- optional = sum(1 for d in self.m.deps if not d.ok and not getattr(d, 'required', True))- if n == 0 and optional:- # nothing is actually blocking: saying "缺 0 项(另有 2 项可选)" reads like a- # problem where there is none- self.deps_summary.setText(self.m.t('dep.onlyOptional', optional))- self.deps_summary.setStyleSheet(f'color: {GREEN}; font-weight: 600;')- return- self.deps_summary.setText(self.m.t('dep.missingOptional', n, optional) if optional- else self.m.t('dep.missing', n))- self.deps_summary.setStyleSheet(f'color: {RED}; font-weight: 600;')+ _set_dot(self.keycheck_dot, style.NEUTRAL_DOT)+ self.keycheck_lbl.setText(t('keycheck.cannotCheck', verdict.reason))+ self.keycheck_row.show()else:- self.deps_summary.setText(self.m.t('dep.checking'))- self.deps_summary.setStyleSheet(f'color: {MUTED};')- missing_installable = [d for d in self.m.deps if not d.ok and d.install]- self.install_all_btn.setVisible(bool(missing_installable))- self.install_all_btn.setEnabled(bool(missing_installable) and- not any(d.installing for d in self.m.deps))+ self.keycheck_row.hide()++ self.out_label.setText(self.m.out_dir or t('build.saveDefault'))+ self.out_clear_btn.setVisible(bool(self.m.out_dir))+ self._refresh_install_card()self._refresh_running()- def _refresh_stages(self) -> None:- while self.stages_container.count():- item = self.stages_container.takeAt(0)- if w := item.widget():- w.deleteLater()- if not self.m.stages:- self.progress_box.setVisible(False)+ def _refresh_target(self) -> None:+ t = self.m.t+ ios = self.m.target == 'ios'+ self.target_title_lbl.setText(t('build.ios') if ios else t('build.mac'))+ self.target_btn.setText(t('target.ios' if ios else 'target.mac'))+ self.target_btn.setToolTip(t('target.tip'))+ self.target_hint.setText(t('target.hint.ios' if ios else 'target.hint.mac'))++ def _toggle_target(self) -> None:+ if self.m.running or pu.IS_WIN:return- self.progress_box.setVisible(True)+ self.m.target = 'mac-app' if self.m.target == 'ios' else 'ios'+ self._refresh_target()++ def _refresh_stages(self) -> None:+ while self.stages_col.count():+ item = self.stages_col.takeAt(0)+ if item.widget():+ item.widget().deleteLater()+ self.stages_card.setVisible(bool(self.m.stages))for st in self.m.stages:- row = QWidget()- h = QHBoxLayout(row)- h.setContentsMargins(0, 0, 0, 0)- h.setSpacing(6)- mark = {'done': '●', 'running': '◐', 'failed': '✕'}.get(st.state, '○')- colour = {'done': GREEN, 'failed': RED}.get(st.state, MUTED)- lab = QLabel(mark)- lab.setFixedWidth(14)- lab.setStyleSheet(f'color: {colour};')- h.addWidget(lab)+ r = QHBoxLayout()+ r.setSpacing(8)+ color = {+ 'done': style.GREEN,+ 'running': style.AMBER,+ 'failed': style.RED,+ }.get(st.state, style.NEUTRAL_DOT)+ r.addWidget(_dot(color))name = QLabel(st.name)- h.addWidget(name, 0)if st.state == 'running':- bar = QProgressBar()- bar.setTextVisible(False)- bar.setFixedWidth(150)- bar.setRange(0, 0)- h.addWidget(bar)- det = QLabel(st.detail)- det.setObjectName('mono')- h.addWidget(det, 1)- self.stages_container.addWidget(row)- done = sum(1 for s in self.m.stages if s.state == 'done')- self.overall.setRange(0, len(self.m.stages))- self.overall.setValue(done)+ name.setStyleSheet('font-weight: 700;')+ elif st.state != 'done':+ name.setObjectName('muted')+ r.addWidget(name)+ detail = QLabel(st.detail if st.state == 'running' else '')+ detail.setObjectName('mono')+ r.addWidget(detail, 1, Qt.AlignRight)+ w = QWidget()+ w.setLayout(r)+ self.stages_col.addWidget(w)+ self._refresh_activity_bar()def _refresh_running(self) -> None:- running = self.m.running- self.build_btn.setText(self.m.t('build.cancel') if running else self.m.t('build.start'))- self.build_btn.setObjectName('danger' if running else 'primary')+ t = self.m.t+ if self.m.running:+ self.build_btn.setText(t('build.cancel'))+ self.build_btn.setObjectName('danger')+ self.build_btn.setEnabled(True)+ else:+ self.build_btn.setText(t('build.start'))+ self.build_btn.setObjectName('primary')+ self.build_btn.setEnabled(self.m.can_build)+ if not self.m.can_build and not self._failed:+ if not self.m.repo_ok:+ why = t('status.chooseRepo')+ elif not self.m.deps_checked:+ why = t('status.checkingDeps')+ elif not self.m.all_deps_ok:+ why = t('status.installFirst')+ elif self.m.game_folder_problem:+ why = t('status.fixFolder')+ else:+ why = t('status.needInputs')+ self.footer.setText(why)+ elif self.m.can_build and not self.m.ipa_path and not self.m.mac_app_path and self.m.failure is None and not self._failed:+ self.footer.setText('')++ # SetupHintCard visibility on Builds page+ setup_needed = not self.m.repo_ok or (self.m.deps_checked and not self.m.all_deps_ok)+ self.setup_hint_card.setVisible(setup_needed)+ if setup_needed:+ self.setup_hint_title.setText(t('library.setupHint'))+ self.setup_hint_sub.setText(t('status.chooseRepo') if not self.m.repo_ok else t('status.installFirst'))+ self.setup_goto_btn.setText(t('nav.settings'))+self.build_btn.style().unpolish(self.build_btn)self.build_btn.style().polish(self.build_btn)- self.build_btn.setEnabled(running or self.m.can_build)- # Re-set on every refresh, and clear when a build runs (the build's own progress text- # takes the footer). "only when empty" wrote the start-up language once and never- # updated it — the footer was English after the toggle.- if running:- self.footer.setText('')- elif getattr(self, '_failed', False):- pass # a failure message stays until the next build: it was being replaced by- # the input reminder on the refresh that follows the failure (issue #52)- elif not self.m.base_path:- self.footer.setText(self.m.t('status.needInputs'))- elif not self.m.repo_ok:- self.footer.setText(self.m.t('status.chooseRepo'))- elif not self.footer.text() or self.footer.text() in (- self.m.t('status.needInputs'), self.m.t('status.chooseRepo')):- self.footer.setText('')+ self._refresh_activity_bar()def _append_log(self, s: str) -> None:- self.log.moveCursor(self.log.textCursor().MoveOperation.End)- self.log.insertPlainText(s)- self.log.moveCursor(self.log.textCursor().MoveOperation.End)- # The shaders are rebuilt: show a popup, once per build.- # Why a popup: a report asked why the shaders were building again, because the log line went unnoticed.+ c = self.log.textCursor()+ c.movePosition(c.MoveOperation.End)+ c.insertText(s)+ self.log.setTextCursor(c)+ self.log.ensureCursorVisible()+ reason = stale_reason(s)+ if reason and not getattr(self, '_stale_shaders_shown', False):+ self._stale_shaders_shown = True- from PySide6.QtWidgets import QMessageBox- box = QMessageBox(QMessageBox.Icon.Information, 'NS Port Builder', self.m.t(TITLE), parent=self)++ box = QMessageBox(QMessageBox.Icon.Information, 'NX2Apple', self.m.t(TITLE), parent=self)+ box.setInformativeText(self.m.t(TEXT[reason]))+ box.exec()def _on_finished(self, ok: bool, note: str) -> None:+ t = self.m.t+ self._failed = not okif ok:- msg = note or self.m.t('msg.done')- if self.m.ipa_path:- msg += ' ' + self.m.t('msg.ipaAt', self.m.ipa_path)- if self.m.archive_path:- msg += ' ' + self.m.t('msg.archiveAt', self.m.archive_path)- self.footer.setStyleSheet(f'color: {GREEN};')+ out = self.m.mac_app_path or self.m.ipa_path+ self.footer.setText(note or (t('status.output', out) if out else t('msg.done')))else:- msg = note or self.m.t('msg.buildFailed')- self.footer.setStyleSheet(f'color: {RED};')- self.footer.setText(msg)- self._failed = not ok- self._show_failure()- if not ok:- # The message points at the log, so put it in view rather than trusting the window to- # be tall enough. ensureWidgetVisible also handles the scroll area's own margin.+ self.footer.setText(note or t('msg.buildFailed'))+ if self._current_page != 'builds':+ self._switch_page('builds')self.scroll.ensureWidgetVisible(self.log, 0, 0)- self.log.setFocus(Qt.OtherFocusReason)- self._refresh_running()+ self._show_failure()+ self.reveal_ipa_btn.hide()+ self.reveal_arc_btn.hide()+ self.reveal_app_btn.setVisible(bool(self.m.mac_app_path) and Path(self.m.mac_app_path).exists())+ self._refresh_install_card()+ self._refresh_library()+ self._refresh_activity_bar()- # ---------------------------------------------------------------- actions+ if self.m.settings_value('notifyOnComplete', True) and not self.isActiveWindow():+ QApplication.beep()- def _toggle_lang(self) -> None:- self.m.toggle_lang()- self._refresh_all()+ # ================================================================ Failure Card Actions- def _build_clicked(self) -> None:- if self.m.running:- self.m.cancel_build()- else:- self.footer.setText('')- self.footer.setStyleSheet('')- self._failed = False- self._stale_shaders_shown = False+ def _show_failure(self) -> None:+ t = self.m.t+ f = self.m.failure+ if f is None or f.kind == bf.UNKNOWN or self.m.running:self.failure_box.hide()- self.m.start_build()+ return+ self.failure_title.setText(t('fail.section'))+ self.failure_what.setText(self.m.failure_what(f))+ self.failure_next.setText(t(f.next_key))+ folder = self.m.failure_folder(f)+ self.failure_folder_btn.setText(t('fail.showFolder'))+ self.failure_folder_btn.setVisible(+ f.kind in (bf.NO_TITLE_ID, bf.SEVERAL_GAMES, bf.DISK_FULL, bf.CLOUD_FOLDER) and bool(folder))+ fix_key = {+ bf.KEYS: 'fail.keys.button',+ bf.CLOUD_FOLDER: 'fail.cloudFolder.button',+ bf.TRANSLATOR: 'fail.translator.button',+ bf.ZBIC: 'fail.zbic.button',+ bf.IOS_SDK: 'fail.iosSDK.button',+ }.get(f.kind)+ if fix_key and (f.kind != bf.IOS_SDK or not pu.IS_WIN):+ self.failure_fix_btn.setText(t(fix_key))+ self.failure_fix_btn.show()+ else:+ self.failure_fix_btn.hide()+ self.failure_anyway_btn.setText(t('fail.buildAnyway'))+ self.failure_anyway_btn.setVisible(bool(f.flag))+ self.failure_box.show()- def _ask_folder(self, title: str) -> str:- d = QFileDialog.getExistingDirectory(self, title)- return d or ''+ def _open_failure_folder(self) -> None:+ if self.m.failure:+ folder = self.m.failure_folder(self.m.failure)+ if folder:+ pu.reveal(folder)- def _ask_file(self, title: str) -> str:- d, _ = QFileDialog.getOpenFileName(self, title, '', 'Metal tools zip (*.zip)')- return d or ''+ def _fix_failure(self) -> None:+ f = self.m.failure+ if f is None:+ return+ if f.kind == bf.KEYS:+ self._pick_input('keys', False)+ elif f.kind == bf.CLOUD_FOLDER:+ self._pick_out_dir()+ else:+ self.m.fix_failure(f)- def _choose_repo(self) -> None:- d = QFileDialog.getExistingDirectory(self, self.m.t('repo.pickMessage'))- if d:- self.m.repo_path = d- self.m.repoChanged.emit()+ def _build_anyway(self) -> None:+ if not self.m.override.request(self.m.failure):+ return+ f = self.m.override.confirming+ assert f is not None+ ans = QMessageBox.question(+ self,+ self.m.t('fail.confirm.title'),+ self.m.t(f'fail.{f.kind}.risk'),+ QMessageBox.Yes | QMessageBox.Cancel,+ QMessageBox.Cancel,+ )+ if ans == QMessageBox.Yes and self.m.override.confirm():+ self._build_clicked()+ else:+ self.m.override.cancel()- def _pick_folder(self) -> None:- d = QFileDialog.getExistingDirectory(self, self.m.t('data.pickFolder'))- if d:- self.m.scan_game_dir(d)+ def _on_app_update(self, tag: str, url: str) -> None:+ self.update_btn.setText(self.m.t('app.updateBtn', tag))+ self.update_btn.setToolTip(url)+ try:+ self.update_btn.clicked.disconnect()+ except (RuntimeError, TypeError):+ pass+ self.update_btn.clicked.connect(lambda: QDesktopServices.openUrl(QUrl(url)))+ self.update_btn.show()- def _choose_input(self, key: str) -> None:- path, _ = QFileDialog.getOpenFileName(self, self.m.t('data.choose'))- if not path:- return- if key == 'base' and inputs.is_game_folder_candidate(path): # a .nup file- self.m.take_game_folder(path)+ # ================================================================ File Pickers & Build Trigger++ def _ask_metal_archive(self, title: str) -> str:+ picked, _ = QFileDialog.getOpenFileName(+ self, title, str(Path.home() / 'Downloads'),+ 'Metal Developer Tools (*.zip *.exe *.msi);;All files (*)')+ if picked:+ return picked+ return QFileDialog.getExistingDirectory(self, title, str(Path.home()))++ def _pick_repo(self) -> None:+ d = QFileDialog.getExistingDirectory(+ self, self.m.t('repo.pickMessage'), self.m.repo_path or str(Path.home()))+ if not d:return- self.m.leave_game_folder() # picking packages leaves the game-folder mode- if key == 'base':- self.m.base_path = path- elif key == 'update':- self.m.update_path = path- elif key == 'keys':- self.m.keys_path = path+ if self.m.is_repo(d):+ self.m.repo_path = d+ self.m.sync_engine()+ self._refresh_repo()+ self._refresh_running()else:- if path not in self.m.dlc_paths:- self.m.dlc_paths.append(path)- self.m.repoChanged.emit()+ QMessageBox.warning(self, self.m.t('repo.title'), self.m.t('repo.notRepo', d))- def _export_log(self) -> None:- """Save the log to a file the user picks, defaulting to the Desktop.-- The window's log is also written to disk as it grows (m.model.log_path); this is for- sending a copy somewhere, e.g. attaching it to an issue from a handheld where copying text- out of the window is awkward.- """- default = str(Path.home() / 'Desktop' / 'ns-port-builder-log.txt')- path, _ = QFileDialog.getSaveFileName(self, self.m.t('log.export'), default,- 'Text (*.txt);;All files (*)')- if not path:+ def _pick_game_dir(self) -> None:+ d = QFileDialog.getExistingDirectory(+ self, self.m.t('data.pickFolder'), self.m.game_dir or self.m.library.games_folder or str(Path.home()))+ if not d:return- try:- Path(path).write_text(self.log.toPlainText(), encoding='utf-8')- self.footer.setText(self.m.t('log.exported', path))- self.footer.setStyleSheet(f'color: {GREEN};')- except OSError as e:- self.footer.setText(self.m.t('log.exportFail', str(e)))- self.footer.setStyleSheet(f'color: {RED};')+ self.m.scan_game_dir(d)+ if not self.m.base_path and self.m.game_folder is None and not self.m.game_folder_problem:+ QMessageBox.information(self, self.m.t('data.title'), self.m.t('data.noBase'))+ elif self.m.base_path:+ g = self.m.library.remember_inputs(+ base_path=self.m.base_path,+ update_path=self.m.update_path,+ dlc_paths=self.m.dlc_paths,+ keys_path=self.m.keys_path,+ output_dir=self.m.out_dir,+ repo_path=self.m.engine_path,+ )+ if g:+ self.m.artwork.request_banner_async(g.title_id)- def _toggle_target(self) -> None:- """Switch between an iPhone IPA and a Mac app (macOS only)."""- self.m.target = 'mac-app' if self.m.target == 'ios' else 'ios'- self.target_btn.setText(self.m.t('target.mac' if self.m.target == 'mac-app' else 'target.ios'))- self.footer.setText(self.m.t('target.hint.mac' if self.m.target == 'mac-app' else 'target.hint.ios'))- self.footer.setStyleSheet('')+ def _pick_input(self, key: str, multi: bool) -> None:+ start = self.m.game_dir or (str(Path(self.m.base_path).parent) if self.m.base_path else str(Path.home()))+ if key == 'keys':+ f, _ = QFileDialog.getOpenFileName(+ self, 'prod.keys', start, 'Keys (prod.keys *.keys *);;All files (*)')+ if f:+ self.m.keys_path = f+ elif multi:+ fs, _ = QFileDialog.getOpenFileNames(+ self, 'DLC', start, 'Switch dumps (*.nsp *.xci *.nsz *.xcz)')+ if fs:+ self.m.leave_game_folder()+ self.m.dlc_paths = fs+ else:+ flt = 'Switch games (*.nsp *.xci *.nsz *.xcz *.nup)' if key == 'base' else 'Switch dumps (*.nsp *.xci *.nsz *.xcz)'+ f, _ = QFileDialog.getOpenFileName(self, key, start, flt)+ if f:+ if key == 'base' and inputs.is_game_folder_candidate(f):+ self.m.take_game_folder(f)+ return+ self.m.leave_game_folder()+ setattr(self.m, f'{key}_path', f)+ self._refresh_inputs()++ def _clear_input(self, key: str) -> None:+ if key == 'base' and (self.m.game_folder is not None or self.m.game_folder_problem):+ self.m.leave_game_folder()+ elif key == 'dlc':+ self.m.dlc_paths = []+ else:+ setattr(self.m, f'{key}_path', '')+ self._refresh_inputs()- def _choose_out(self) -> None:- d = QFileDialog.getExistingDirectory(self, self.m.t('build.outDir'))+ def _pick_out_dir(self) -> None:+ d = QFileDialog.getExistingDirectory(+ self, self.m.t('build.outDir'), self.m.out_dir or str(Path.home()))if d:self.m.out_dir = d- self._refresh_all()+ self._refresh_inputs()++ def _clear_out_dir(self) -> None:+ self.m.out_dir = ''+ self._refresh_inputs()++ def _build_clicked(self) -> None:+ if self.m.running:+ self.m.cancel_build()+ return+ self._failed = False++ self._stale_shaders_shown = False+ self.reveal_ipa_btn.hide()+ self.reveal_arc_btn.hide()+ self.reveal_app_btn.hide()+ self.footer.setText('')+ self.m.start_build()++ # ================================================================ Full-Window Drag & Drop++ def resizeEvent(self, event) -> None:+ super().resizeEvent(event)+ if hasattr(self, 'top_bar'):+ self.top_bar.recenter_nav()+ if hasattr(self, 'drop_overlay') and self.centralWidget():+ self.drop_overlay.setGeometry(self.centralWidget().rect())++ def mousePressEvent(self, event: QMouseEvent) -> None:+ if event.button() == Qt.LeftButton and not self.isMaximized():+ pos = event.position().toPoint()+ margin = 6+ edges = Qt.Edges()+ if pos.x() <= margin:+ edges |= Qt.LeftEdge+ elif pos.x() >= self.width() - margin:+ edges |= Qt.RightEdge+ if pos.y() <= margin:+ edges |= Qt.TopEdge+ elif pos.y() >= self.height() - margin:+ edges |= Qt.BottomEdge+ if edges:+ wh = self.windowHandle()+ if wh is not None and hasattr(wh, 'startSystemResize'):+ if wh.startSystemResize(edges):+ event.accept()+ return+ super().mousePressEvent(event)++ def dragEnterEvent(self, event: QDragEnterEvent) -> None:+ if event.mimeData().hasUrls():+ event.acceptProposedAction()+ self.drop_overlay.set_hint(self.m.t('drop.hint'))+ self.drop_overlay.setGeometry(self.centralWidget().rect())+ self.drop_overlay.raise_()+ self.drop_overlay.show()++ def dragLeaveEvent(self, _event) -> None:+ self.drop_overlay.hide()++ def dropEvent(self, event: QDropEvent) -> None:+ self.drop_overlay.hide()+ urls = event.mimeData().urls()+ paths = [u.toLocalFile() for u in urls if u.isLocalFile()]+ if not paths:+ return+ event.acceptProposedAction()++ pkg_files: list[Path] = []+ for p in paths:+ if os.path.isdir(p):+ self.m.scan_game_dir(p)+ self._switch_page('builds')+ self._refresh_all()+ return+ low = os.path.basename(p).lower()+ if low == 'prod.keys' or low.endswith('.keys'):+ self.m.keys_path = p+ elif low.endswith('.nup'):+ self.m.take_game_folder(p)+ elif os.path.splitext(low)[1] in inputs.GAME_SUFFIXES:+ pkg_files.append(Path(p))++ if pkg_files:+ self.m.leave_game_folder()+ classified = inputs.classify(pkg_files)+ if classified.get('base'):+ self.m.base_path = str(classified['base'])+ if classified.get('update'):+ self.m.update_path = str(classified['update'])+ if classified.get('dlc'):+ self.m.dlc_paths = [str(x) for x in classified['dlc']]++ if self.m.base_path:+ g = self.m.library.remember_inputs(+ base_path=self.m.base_path,+ update_path=self.m.update_path,+ dlc_paths=self.m.dlc_paths,+ keys_path=self.m.keys_path,+ output_dir=self.m.out_dir,+ repo_path=self.m.engine_path,+ )+ if g:+ self.m.artwork.request_banner_async(g.title_id)++ self._switch_page('builds')+ self._refresh_all()