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 PR #82 into main: the save-transfer sheet and the Free-space sheet share the controller
LNPANDYf65fd76603cc
diff --cc frontend/Sources/NSPortBuilder/LauncherView.swiftindex 6f9b22a7,591fab44..20286b83--- a/frontend/Sources/NSPortBuilder/LauncherView.swift+++ b/frontend/Sources/NSPortBuilder/LauncherView.swift@@@ -34,8 -34,8 +34,9 @@@ struct ContentView: View@State private var launchError: String?@State private var removing: LibraryGame?@State private var optionsFor: UUID?+ @State private var freeSpaceFor: UUID? // the game whose Free space sheet is open@State private var controlsOpen = false+ @State private var savesFor: UUID? // the game whose Saves sheet is open (SaveTransfer.swift)@StateObject private var controls = ControlLayout()@StateObject private var gamepad = LauncherGamepad()@StateObject private var padFocus = PadFocus()@@@ -128,11 -148,11 +149,15 @@@if let id = optionsFor { LaunchOptionsView(m: m, library: library, gameID: id).environmentObject(padFocus) }}.sheet(isPresented: $controlsOpen) { ControlsView(m: m, layout: controls).environmentObject(padFocus) }+ .sheet(isPresented: Binding(get: { freeSpaceFor != nil }, set: { if !$0 { freeSpaceFor = nil } })) {+ if let game = library.games.first(where: { $0.id == freeSpaceFor }) { FreeSpaceView(m: m, game: game).environmentObject(padFocus) }+ }+ .onChange(of: freeSpaceFor) { id in padFocus.scope = id != nil ? "free" : "main" }.sheet(isPresented: $m.showUpdateSheet) { UpdateSheet(m: m) }+ .sheet(isPresented: Binding(get: { savesFor != nil }, set: { if !$0 { savesFor = nil } })) {+ if let id = savesFor { SavesView(m: m, library: library, gameID: id).environmentObject(padFocus) }+ }+ .onChange(of: savesFor) { id in padFocus.scope = id != nil ? "saves" : "main" }.onChange(of: optionsFor) { id in padFocus.scope = id != nil ? "launch" : (controlsOpen ? "controls" : "main") }.onChange(of: controlsOpen) { open in padFocus.scope = open ? "controls" : (optionsFor != nil ? "launch" : "main") }.onChange(of: page) { _ in padFocus.focused = nil }@@@ -316,9 -350,8 +355,9 @@@.padTarget("hero.options", scope: "main", radius: 24) { optionsFor = game.id }}Menu {- Button(m.t("library.buildAgain")) { configureBuild(game) }.disabled(m.running || game.inputs["base", default: []].isEmpty)+ Button(m.t(toolsAge.older.contains(game.id) ? "library.rebuild" : "library.buildAgain")) { configureBuild(game) }.disabled(m.running || game.inputs["base", default: []].isEmpty)if game.isReady { Button(m.t("launch.title")) { optionsFor = game.id } }+ Button(m.t("saves.menu")) { savesFor = game.id }Button(m.t("library.changeArtwork")) { chooseArtwork(game) }if !game.artworkPath.isEmpty {Button(m.t("library.resetArtwork")) { library.setArtwork("", for: game.id) }@@@ -537,8 -575,9 +582,10 @@@/// then the D-pad moves it (PadFocus), A activates, B closes a sheet or goes back to the library, X opens the selected/// game's launch options, L and R switch the pages.private func padAction(_ action: LauncherGamepad.Action) {- let sheetOpen = optionsFor != nil || controlsOpen || savesFor != nil- let sheetOpen = optionsFor != nil || controlsOpen++ let sheetOpen = optionsFor != nil || controlsOpen || savesFor != nil || freeSpaceFor != nil+ if action == .b, savesFor != nil { savesFor = nil; return }+ // The Free space sheet: B closes it, the D-pad and A work in it, X, L and R do nothing behind it+ if freeSpaceFor != nil && [.b, .x, .l, .r].contains(action) { if action == .b { freeSpaceFor = nil }; return }if action == .b {if optionsFor != nil { optionsFor = nil } else if controlsOpen { controlsOpen = false }else if searching { searching = false; search = "" } else if page != .library { page = .library }