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
Qt front end: the Mac launcher's palette, Manrope and control styles
v0lumehi14953cea445c
diff --git a/.github/workflows/build-qt.yml b/.github/workflows/build-qt.ymlindex 934bb2cb..b2c5d1dd 100644--- a/.github/workflows/build-qt.yml+++ b/.github/workflows/build-qt.yml@@ -42,6 +42,9 @@ jobs:working-directory: frontend-qtshell: bashrun: |+ # Manrope (the Mac launcher's typeface, SIL OFL 1.1) goes into the bundle's fonts folder+ # with its licence; style.load_font() looks for it there.+ PATHSEP=';'# --windowed: no console window. --name: the exe/bundle name.# --collect-all PySide6 copies the whole PySide6 package and OVERRIDES# --exclude-module (measured: the package stayed 247 MB with 38 exclusions in@@ -103,6 +106,8 @@ jobs:--exclude-module PySide6.QtHttpServer \--exclude-module PySide6.QtGraphs \--exclude-module PySide6.QtGraphsWidgets \+ --add-data "../frontend/fonts/Manrope.ttf${PATHSEP}fonts" \+ --add-data "../frontend/fonts/Manrope-OFL.txt${PATHSEP}fonts" \--paths . \run_gui.pydiff --git a/frontend-qt/README.md b/frontend-qt/README.mdindex 4c9e93d1..809c76e4 100644--- a/frontend-qt/README.md+++ b/frontend-qt/README.md@@ -30,6 +30,13 @@ python3 -m venv .venvFrom this folder. It looks for the repository checkout next to itself, in `~/NX2Apple`, orwherever `NSPB_REPO` points, and the repository group lets you pick it by hand.+## Look++`nspb_qt/style.py` follows the Mac launcher: near-black background, cream accent, the state colours+of its `LauncherPalette`, and the Manrope typeface (SIL OFL 1.1). The font is not copied here: a+source run loads `../frontend/fonts/Manrope.ttf`, and the Windows build adds it and its licence to+the bundle's `fonts` folder (`build-qt.yml`). If the file is missing the system font is used.+## What works today- Dependency detection per platform: Python + packages, .NET SDK, and either **Xcode + iOS SDK +diff --git a/frontend-qt/nspb_qt/__main__.py b/frontend-qt/nspb_qt/__main__.pyindex d58bc669..70f73edb 100644--- a/frontend-qt/nspb_qt/__main__.py+++ b/frontend-qt/nspb_qt/__main__.py@@ -9,7 +9,7 @@ from PySide6.QtWidgets import QApplicationfrom .model import Modelfrom .platform_util import hide_console_for_children-from .style import STYLE+from .style import STYLE, load_fontfrom .ui import MainWindow@@ -27,6 +27,11 @@ def main() -> int:app.setApplicationDisplayName('NS Port Builder')app.setStyleSheet(STYLE)app.setStyle('Fusion') # the same widget look on Windows and macOS+ family = load_font() # Manrope, as the Mac launcher; the system font when it cannot load+ if family:+ font = app.font()+ font.setFamily(family)+ app.setFont(font)model = Model()win = MainWindow(model)win.show()diff --git a/frontend-qt/nspb_qt/style.py b/frontend-qt/nspb_qt/style.pyindex f6681be1..f8796db0 100644--- a/frontend-qt/nspb_qt/style.py+++ b/frontend-qt/nspb_qt/style.py@@ -1,24 +1,67 @@-"""Visual language: the dark card look of the SwiftUI app, in Qt style sheets.+"""Visual language: the Mac launcher's near-black look with a cream accent, in Qt style sheets.-The SwiftUI window uses rounded cards on a dark background, a coloured dot per state and-monospaced secondary text. Qt can do all of that with a style sheet; keeping it in one module-means the two front ends stay recognisable as the same product.+The palette, the Manrope typeface and the control shapes follow the SwiftUI launcher+(`frontend/Sources/NSPortBuilder/LauncherView.swift` LauncherPalette and `LauncherStyles.swift`),+so the two front ends stay recognisable as the same product. The translucent white fills of the+Mac controls are pre-mixed here into opaque colours, since a Qt style sheet has no cheap overlay."""from __future__ import annotations-# The palette, taken from the SwiftUI app's screenshots.-BG = '#1c1f24' # window background-CARD = '#252a31' # a card's fill-CARD_EDGE = '#31373f' # a card's hairline-TEXT = '#e6e9ed'-MUTED = '#8b949e'-PATH = '#6b7480' # a filesystem path in a dependency row: dimmer than prose, so the eye+import os+import sys++# The palette: LauncherPalette's values as hex.+BG = '#0e0e0f' # window background, rgb(0.055, 0.055, 0.06)+CARD = '#1a1a1c' # a card's fill (the launcher's "surface"), rgb(0.10, 0.10, 0.11)+CARD_EDGE = '#2c2c2e' # a card's hairline: white at 8% over the surface+TEXT = '#ebebeb' # white at 92%, as the launcher's button labels+MUTED = '#91949c' # the launcher's "unbuilt" grey+PATH = '#6f7178' # a filesystem path in a dependency row: dimmer than prose, so the eye# reads the hint beside it first (the report asked for exactly this)-HINT = '#9aa4b0' # a hint or explanation: a step brighter than the path it sits next to-GREEN = '#34c759' # ok / done-ORANGE = '#ff9f0a' # attention-RED = '#ff453a' # missing / failed-ACCENT = '#0a84ff' # buttons+HINT = '#a8aab0' # a hint or explanation: a step brighter than the path it sits next to+CREAM = '#fff0d6' # the accent: primary buttons, switches, the chosen choice+GREEN = '#40d678' # ok / done: the launcher's "ready"+ORANGE = '#ffc73d' # attention: the launcher's "building"+RED = '#ff6b66' # missing / failed: the launcher's destructive red++# Controls, as white over the background at the launcher's opacities.+BTN = '#1b1b1c' # white 5.5%+BTN_HOVER = '#242425' # white 9%+BTN_PRESSED = '#2d2d2e' # white 13%+BTN_EDGE = '#262627' # white 10%+FIELD = '#161617' # an input: a touch above the background+TRACK = '#262627' # a slider or progress track: white 10%++MONO = 'Menlo, Consolas, monospace'+++def _font_file():+ """Manrope.ttf: in the bundle's `fonts` folder in a frozen build (build-qt.yml adds it), in+ the repository's frontend/fonts, the copy the Mac app embeds, in a source run."""+ if getattr(sys, 'frozen', False):+ base = getattr(sys, '_MEIPASS', os.path.dirname(sys.executable))+ candidates = [os.path.join(base, 'fonts', 'Manrope.ttf'),+ os.path.join(os.path.dirname(sys.executable), 'fonts', 'Manrope.ttf')]+ else:+ here = os.path.dirname(os.path.abspath(__file__))+ candidates = [os.path.join(here, '..', '..', 'frontend', 'fonts', 'Manrope.ttf')]+ for c in candidates:+ if os.path.isfile(c):+ return c+ return None+++def load_font() -> str:+ """Registers Manrope with Qt and returns its family name, or '' (keep the system font)+ when the file is missing or Qt rejects it."""+ path = _font_file()+ if path is None:+ return ''+ from PySide6.QtGui import QFontDatabase+ fid = QFontDatabase.addApplicationFont(path)+ families = QFontDatabase.applicationFontFamilies(fid) if fid >= 0 else []+ return families[0] if families else ''+STYLE = f"""QMainWindow, QDialog, QScrollArea, QWidget#body {{@@ -40,46 +83,51 @@ QScrollArea > QWidget > QWidget {{QFrame#card {{background: {CARD};border: 1px solid {CARD_EDGE};- border-radius: 8px;+ border-radius: 10px;}}-/* ---- buttons ---- */+/* ---- buttons: white 5.5% on the background, a 10% hairline, radius 9 ---- */QPushButton {{- background: #333a43;- border: 1px solid #3d444d;- border-radius: 6px;- padding: 3px 10px; /* compact: a 7-inch panel must fit the whole form */+ background: {BTN};+ border: 1px solid {BTN_EDGE};+ border-radius: 9px;+ padding: 4px 7px; /* compact: a 7-inch panel must fit the whole form */color: {TEXT};+ font-weight: 600;}}-QPushButton:hover {{ background: #3c444e; }}-QPushButton:pressed {{ background: #2b3138; }}-QPushButton:disabled {{ color: #5c646e; background: #2a2f36; border-color: #333940; }}+QPushButton:hover {{ background: {BTN_HOVER}; }}+QPushButton:pressed {{ background: {BTN_PRESSED}; }}+QPushButton:disabled {{ color: #5a5b60; background: {BTN}; border-color: #1e1e1f; }}+/* the primary action: cream fill, dark text */QPushButton#primary {{- background: {ACCENT};- border: none;- color: white;+ background: {CREAM};+ border: 1px solid {CREAM};+ color: {BG};font-size: 10pt;- font-weight: 600;+ font-weight: 700;padding: 6px 16px;}}-QPushButton#primary:hover {{ background: #3a9bff; }}-QPushButton#primary:disabled {{ background: #2c3a4a; color: #6b7683; }}+QPushButton#primary:hover {{ background: #fff6e6; border-color: #fff6e6; }}+QPushButton#primary:pressed {{ background: #e8d9bf; border-color: #e8d9bf; }}+QPushButton#primary:disabled {{ background: #2a2822; border-color: #2a2822; color: #6d6a62; }}+/* a stop or destructive action: the secondary button in red, as the build bar's Stop */QPushButton#danger {{- background: {RED};- border: none;- color: white;+ background: {BTN};+ border: 1px solid #a14a48;+ color: {RED};font-size: 10pt;font-weight: 600;padding: 6px 16px;}}+QPushButton#danger:hover {{ background: {BTN_HOVER}; }}/* ---- labels ---- */-QLabel#title {{ font-size: 17pt; font-weight: 700; background: transparent; }}+QLabel#title {{ font-size: 17pt; font-weight: 800; background: transparent; }}QLabel#subtitle {{ color: {MUTED}; font-size: 9pt; background: transparent; }}QLabel#note {{ color: {HINT}; font-size: 8pt; background: transparent; }}-QLabel#mono {{ color: {PATH}; font-family: Menlo, Consolas, monospace; font-size: 8pt; background: transparent; }}+QLabel#mono {{ color: {PATH}; font-family: {MONO}; font-size: 8pt; background: transparent; }}QLabel#ok {{ color: {GREEN}; font-weight: 600; background: transparent; }}QLabel#warn {{ color: {ORANGE}; font-weight: 600; }}QLabel#bad {{ color: {RED}; font-weight: 600; background: transparent; }}@@ -88,18 +136,20 @@ QLabel#footer {{ color: {MUTED}; font-size: 8pt; padding: 4px 2px; background: t/* ---- the log ---- */QTextEdit {{- background: #14171b;+ background: {FIELD};border: 1px solid {CARD_EDGE};- border-radius: 8px;+ border-radius: 10px;padding: 8px;- color: #b9c2cc;- font-family: Menlo, Consolas, monospace;+ color: #b9bbc1;+ font-family: {MONO};font-size: 8pt;+ selection-background-color: #5a5445;+ selection-color: {TEXT};}}/* ---- progress ---- */QProgressBar {{- background: #2a2f36;+ background: {TRACK};border: none;border-radius: 4px;height: 7px;@@ -118,21 +168,87 @@ QScrollBar:vertical {{margin: 0;}}QScrollBar::handle:vertical {{- background: #3d444d;+ background: #34343a;border-radius: 5px;min-height: 30px;}}-QScrollBar::handle:vertical:hover {{ background: #4a525c; }}+QScrollBar::handle:vertical:hover {{ background: #46464d; }}QScrollBar::add-line:vertical, QScrollBar::sub-line:vertical {{ height: 0; }}QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {{ background: transparent; }}+QScrollBar:horizontal {{+ background: transparent;+ height: 10px;+ margin: 0;+}}+QScrollBar::handle:horizontal {{+ background: #34343a;+ border-radius: 5px;+ min-width: 30px;+}}+QScrollBar::handle:horizontal:hover {{ background: #46464d; }}+QScrollBar::add-line:horizontal, QScrollBar::sub-line:horizontal {{ width: 0; }}+QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {{ background: transparent; }}/* ---- dialogs inherit the dark look ---- */-QFileDialog, QMessageBox {{ background: {BG}; }}+QFileDialog, QMessageBox, QInputDialog {{ background: {BG}; }}QLineEdit, QComboBox {{- background: #2a2f36;+ background: {FIELD};+ border: 1px solid {BTN_EDGE};+ border-radius: 9px;+ padding: 5px 9px;+ color: {TEXT};+ selection-background-color: #5a5445;+ selection-color: {TEXT};+}}+QLineEdit:focus, QComboBox:focus {{ border-color: {CREAM}; }}+QComboBox::drop-down {{ border: none; width: 20px; }}+QComboBox QAbstractItemView {{+ background: {CARD};+ border: 1px solid {CARD_EDGE};+ color: {TEXT};+ selection-background-color: {BTN_PRESSED};+ selection-color: {TEXT};+ outline: none;+}}++/* ---- menus and tooltips ---- */+QMenu {{+ background: {CARD};border: 1px solid {CARD_EDGE};- border-radius: 6px;- padding: 5px 8px;+ border-radius: 9px;+ padding: 6px;+}}+QMenu::item {{ padding: 6px 14px; border-radius: 7px; }}+QMenu::item:selected {{ background: {BTN_PRESSED}; }}+QMenu::item:disabled {{ color: #5a5b60; }}+QMenu::separator {{ height: 1px; background: {CARD_EDGE}; margin: 4px 6px; }}+QToolTip {{+ background: {CARD};color: {TEXT};+ border: 1px solid {CARD_EDGE};+ padding: 4px 6px;+}}++/* ---- check boxes: the launcher's switch in cream when on ---- */+QCheckBox {{ spacing: 8px; background: transparent; }}+QCheckBox::indicator {{+ width: 32px;+ height: 18px;+ border-radius: 9px;+ background: #2a2a2c;+ border: none;+}}+QCheckBox::indicator:checked {{ background: {CREAM}; }}+QCheckBox::indicator:disabled {{ background: #1e1e1f; }}++/* ---- sliders: a thin track with a cream fill and knob ---- */+QSlider::groove:horizontal {{ height: 4px; border-radius: 2px; background: {TRACK}; }}+QSlider::sub-page:horizontal {{ height: 4px; border-radius: 2px; background: {CREAM}; }}+QSlider::handle:horizontal {{+ background: {CREAM};+ width: 16px;+ height: 16px;+ margin: -6px 0;+ border-radius: 8px;}}"""diff --git a/frontend-qt/nspb_qt/ui.py b/frontend-qt/nspb_qt/ui.pyindex 219736fd..199054b3 100644--- a/frontend-qt/nspb_qt/ui.py+++ b/frontend-qt/nspb_qt/ui.py@@ -16,7 +16,7 @@ from PySide6.QtWidgets import (from . import platform_util as pufrom .model import DepState, Model-from .style import GREEN, MUTED, ORANGE, RED+from .style import CARD_EDGE, GREEN, MUTED, ORANGE, REDclass MainWindow(QMainWindow):@@ -442,7 +442,7 @@ class MainWindow(QMainWindow):def _separator() -> QFrame:line = QFrame()line.setFrameShape(QFrame.HLine)- line.setStyleSheet('color: #31373f;')+ line.setStyleSheet(f'color: {CARD_EDGE};')return line# ---------------------------------------------------------------- refresh