Manic EMU is an all-in-one retro game emulator for iOS. It packs powerful features while keeping a clean, sleek UI and delivering buttery-smooth gameplay.
Swift
UI upgraded to modern layout logic
Daiuno09af0c114499
diff --git a/Dependencies/DeltaCore b/Dependencies/DeltaCoreindex a9ed6eb8..339082e0 160000--- a/Dependencies/DeltaCore+++ b/Dependencies/DeltaCore@@ -1 +1 @@-Subproject commit a9ed6eb83913865a5613b666724ebd414c226eca+Subproject commit 339082e079fcf020de9bb6653dd1aac7f2cbbd3cdiff --git a/Dependencies/ProHUD b/Dependencies/ProHUDindex bbded704..40669542 160000--- a/Dependencies/ProHUD+++ b/Dependencies/ProHUD@@ -1 +1 @@-Subproject commit bbded7047d8c594a024369c2f58b0238f4817e4c+Subproject commit 40669542554dd928ad69652a925a1c591f4e8264diff --git a/ManicEmu/ManicEmu.xcodeproj/project.pbxproj b/ManicEmu/ManicEmu.xcodeproj/project.pbxprojindex c834b1e8..bf491c70 100644--- a/ManicEmu/ManicEmu.xcodeproj/project.pbxproj+++ b/ManicEmu/ManicEmu.xcodeproj/project.pbxproj@@ -1644,7 +1644,13 @@E2CFD49A14B2461EA3CBFA66 /* SwiftSoup in Frameworks */ = {isa = PBXBuildFile; productRef = 575A39CB2DCCFA6B00B28FC2 /* SwiftSoup */; };E2EA5DEE0D384C1281D9CF83 /* WebDavKit in Frameworks */ = {isa = PBXBuildFile; productRef = 57F632E22D714E46007270E8 /* WebDavKit */; };E4DFA97292C840F29BC49ED5 /* RuffleView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8B188E5A6DD343E5960ABEF0 /* RuffleView.swift */; };+ E520DED8306E9606003F83BE /* UIViewControllerExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = E520DED7306E95FC003F83BE /* UIViewControllerExtensions.swift */; };+ E520DED9306E9606003F83BE /* UIViewControllerExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = E520DED7306E95FC003F83BE /* UIViewControllerExtensions.swift */; };+ E520DEDA306E9606003F83BE /* UIViewControllerExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = E520DED7306E95FC003F83BE /* UIViewControllerExtensions.swift */; };E5385955E04D43598CAC5694 /* vice.x64sc.libretro.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 6A6021052A14459DA6F729AB /* vice.x64sc.libretro.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };+ E5A00BB23080B2CC00E99223 /* ProHUDExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5A00BB13080B2C200E99223 /* ProHUDExtensions.swift */; };+ E5A00BB33080B2CC00E99223 /* ProHUDExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5A00BB13080B2C200E99223 /* ProHUDExtensions.swift */; };+ E5A00BB43080B2CC00E99223 /* ProHUDExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = E5A00BB13080B2C200E99223 /* ProHUDExtensions.swift */; };E977CAA1F3C34827833FAF30 /* XCGLogger in Frameworks */ = {isa = PBXBuildFile; productRef = 5713306D2D91AFE00043C28A /* XCGLogger */; };EAE31C39F6FF42DE8F5BA497 /* Schedule in Frameworks */ = {isa = PBXBuildFile; productRef = 57C759192FD42D030093A2B3 /* Schedule */; };EE7572E891E3420A86A7E33F /* CollectionViewPagingLayout in Frameworks */ = {isa = PBXBuildFile; productRef = 578E20902FD16DA500A2749A /* CollectionViewPagingLayout */; };@@ -6831,6 +6837,8 @@B2F4B7AF2A138C74003B0E07 /* PhotoSaver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhotoSaver.swift; sourceTree = "<group>"; };B2F4B7B12A147226003B0E07 /* UIViewExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIViewExtensions.swift; sourceTree = "<group>"; };B93489E15EFD47F2AE825436 /* Amiga.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Amiga.swift; sourceTree = "<group>"; };+ E520DED7306E95FC003F83BE /* UIViewControllerExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIViewControllerExtensions.swift; sourceTree = "<group>"; };+ E5A00BB13080B2C200E99223 /* ProHUDExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProHUDExtensions.swift; sourceTree = "<group>"; };F0C500000000000000000101 /* FocusTypes.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FocusTypes.swift; sourceTree = "<group>"; };F0C500000000000000000102 /* Focusable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Focusable.swift; sourceTree = "<group>"; };F0C500000000000000000103 /* FocusContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FocusContainer.swift; sourceTree = "<group>"; };@@ -13381,6 +13389,8 @@579C114C2D1D0E0A00CFD1F5 /* UIWindowExtensions.swift */,57E01004300B85ED009AA38C /* UIEdgeInsetsExtensions.swift */,57D483A930217B010030A771 /* SequenceExtensions.swift */,+ E520DED7306E95FC003F83BE /* UIViewControllerExtensions.swift */,+ E5A00BB13080B2C200E99223 /* ProHUDExtensions.swift */,);path = Extensions;sourceTree = "<group>";@@ -13970,6 +13980,7 @@579093FC303C7D9100A53656 /* SymbianDeviceView.swift in Sources */,579093FD303C7D9100A53656 /* SaveStateListView.swift in Sources */,579093FE303C7D9100A53656 /* ASBorderStyle.swift in Sources */,+ E520DEDA306E9606003F83BE /* UIViewControllerExtensions.swift in Sources */,579093FF303C7D9100A53656 /* GameCheat.swift in Sources */,57909400303C7D9100A53656 /* GBA.swift in Sources */,57909401303C7D9100A53656 /* WFC.swift in Sources */,@@ -13980,6 +13991,7 @@57909406303C7D9100A53656 /* ASListToolView.swift in Sources */,57909407303C7D9100A53656 /* PhotoSaver.swift in Sources */,57909408303C7D9100A53656 /* PurchaseManager.swift in Sources */,+ E5A00BB43080B2CC00E99223 /* ProHUDExtensions.swift in Sources */,57909409303C7D9100A53656 /* FlexItemView.swift in Sources */,5790940A303C7D9100A53656 /* BlankSlateCollectionView.swift in Sources */,5790940B303C7D9100A53656 /* System.swift in Sources */,@@ -14440,6 +14452,7 @@57BA2DA5303593670039E284 /* SymbianDeviceView.swift in Sources */,57F1D4372FF3879200FC5B2A /* SaveStateListView.swift in Sources */,5796DB1A2FE4181D0051F661 /* ASBorderStyle.swift in Sources */,+ E520DED8306E9606003F83BE /* UIViewControllerExtensions.swift in Sources */,57CDCDE32FD5CBD3005BA4C8 /* GameCheat.swift in Sources */,57CDCDE42FD5CBD3005BA4C8 /* GBA.swift in Sources */,57CDCDE52FD5CBD3005BA4C8 /* WFC.swift in Sources */,@@ -14450,6 +14463,7 @@57BF60962FE2ABF70073D318 /* ASListToolView.swift in Sources */,57CDCDEA2FD5CBD3005BA4C8 /* PhotoSaver.swift in Sources */,57CDCDEC2FD5CBD3005BA4C8 /* PurchaseManager.swift in Sources */,+ E5A00BB23080B2CC00E99223 /* ProHUDExtensions.swift in Sources */,577160AF30078D680088345B /* FlexItemView.swift in Sources */,57CDCDED2FD5CBD3005BA4C8 /* BlankSlateCollectionView.swift in Sources */,57CDCDEE2FD5CBD3005BA4C8 /* System.swift in Sources */,@@ -14813,6 +14827,7 @@57FD14143011C73D007F211A /* ShaderPreviewView.swift in Sources */,572D026B2F87E3F8000BD6F4 /* PretendoNetworkingView.swift in Sources */,57DFBE8C2E71BC7A008C2161 /* CheevosPopupView.swift in Sources */,+ E5A00BB33080B2CC00E99223 /* ProHUDExtensions.swift in Sources */,576C4BE7304174AA00DB526E /* FocusSoundEffects.swift in Sources */,578E4B592F8A2F480027E6D0 /* GlobalCoreSwitch.swift in Sources */,57D482B33019D3330030A771 /* ASListCustomCollectionCell.swift in Sources */,@@ -15131,6 +15146,7 @@57F3BAEC2F6541C900ABF4B3 /* J2MESettingView.swift in Sources */,57DF847A2D62E98100AA0AAB /* NSAttributedStringExtensions.swift in Sources */,577160F0300931900088345B /* RetroAchievementsLaunchView.swift in Sources */,+ E520DED9306E9606003F83BE /* UIViewControllerExtensions.swift in Sources */,576F0DA52D85CD3A00D2A1BA /* FeaturesCell.swift in Sources */,57CC33BA2DBCD90700DF7418 /* AuxiliaryLineView.swift in Sources */,57BA2D9430357F200039E284 /* SymbianFirmwareView.swift in Sources */,diff --git a/ManicEmu/ManicEmu.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ManicEmu/ManicEmu.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolvedindex 7899a045..5e8e7f13 100644--- a/ManicEmu/ManicEmu.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved+++ b/ManicEmu/ManicEmu.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved@@ -105,7 +105,7 @@"location" : "https://github.com/Ekhoo/Device.git","state" : {"branch" : "master",- "revision" : "71e601c9b2ad1ca413b69cdab52009f78625060f"+ "revision" : "c5efafa1c0cbacae4efcf9a2c1bb165976a44d7a"}},{diff --git a/ManicEmu/ManicEmu/Resources/Info.plist b/ManicEmu/ManicEmu/Resources/Info.plistindex f8eb0084..aae85d27 100644--- a/ManicEmu/ManicEmu/Resources/Info.plist+++ b/ManicEmu/ManicEmu/Resources/Info.plist@@ -729,7 +729,7 @@<string>armv7</string></array><key>UIRequiresFullScreen</key>- <true/>+ <false/><key>UIStatusBarHidden</key><true/><key>UIStatusBarStyle</key>diff --git a/ManicEmu/ManicEmu/Sources/Base/AppDelegate.swift b/ManicEmu/ManicEmu/Sources/Base/AppDelegate.swiftindex 3ecc93f2..c28597e6 100644--- a/ManicEmu/ManicEmu/Sources/Base/AppDelegate.swift+++ b/ManicEmu/ManicEmu/Sources/Base/AppDelegate.swift@@ -44,7 +44,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {UIViewController.attemptRotationToDeviceOrientation()}if #available(iOS 16.0, *) {- var vc = ApplicationSceneDelegate.applicationWindow?.rootViewController+ var vc = UIWindow.applicationWindow?.rootViewControllerwhile let current = vc {current.setNeedsUpdateOfSupportedInterfaceOrientations()if #available(iOS 26.0, *) {diff --git a/ManicEmu/ManicEmu/Sources/Base/ApplicationSceneDelegate.swift b/ManicEmu/ManicEmu/Sources/Base/ApplicationSceneDelegate.swiftindex 2444415c..0a929b63 100644--- a/ManicEmu/ManicEmu/Sources/Base/ApplicationSceneDelegate.swift+++ b/ManicEmu/ManicEmu/Sources/Base/ApplicationSceneDelegate.swift@@ -154,7 +154,7 @@ class ApplicationSceneDelegate: UIResponder, UIWindowSceneDelegate {Self.launchGameID = nillet realm = Database.realmif let game = realm.object(ofType: Game.self, forPrimaryKey: launchGameID) {- game.handleTapAction(forceQuick: true)+ game.handleTapAction(forceQuick: true, in: nil)}}@@ -187,12 +187,34 @@ class ApplicationSceneDelegate: UIResponder, UIWindowSceneDelegate {}DispatchQueue.main.asyncAfter(delay: 1.5) {if newFileUrls.count > 0 {- FilesImporter.importFiles(urls: newFileUrls)+ FilesImporter.importFiles(urls: newFileUrls, in: nil)}}}}}++ func windowScene(_ windowScene: UIWindowScene, didUpdate previousCoordinateSpace: any UICoordinateSpace, interfaceOrientation previousInterfaceOrientation: UIInterfaceOrientation, traitCollection previousTraitCollection: UITraitCollection) {+ if #available(iOS 26.0, tvOS 26.0, *) {+ return+ }+ //Use this method to handle the following geometry changes in iOS26 and below.+ }++ @available(iOS 26.0, tvOS 26.0, *)+ func windowScene(_ windowScene: UIWindowScene, didUpdateEffectiveGeometry previousEffectiveGeometry: UIWindowScene.Geometry) {+ //Use this method to handle the following geometry changes above iOS26.+ }++ @available(iOS 27.0, tvOS 27.0, *)+ func supportedInterfaceOrientations(for windowScene: UIWindowScene) -> UIInterfaceOrientationMask {+ return OrientationLockPin.resolvedMask(for: window)+ }++ @available(iOS 26.0, tvOS 26.0, *)+ func preferredWindowingControlStyle(for windowScene: UIWindowScene) -> UIWindowScene.WindowingControlStyle {+ return .minimal+ }}extension ApplicationSceneDelegate: UIDropInteractionDelegate {@@ -257,7 +279,7 @@ extension ApplicationSceneDelegate: UIDropInteractionDelegate {// 所有操作完成后刷新UIdispatchGroup.notify(queue: .main) {if urls.count > 0 {- FilesImporter.importFiles(urls: urls, preErrors: errors)+ FilesImporter.importFiles(urls: urls, preErrors: errors, in: nil)} else {UIView.hideLoading()UIView.makeToast(message: R.string.localizable.dropErrorLoadFailed())diff --git a/ManicEmu/ManicEmu/Sources/Base/Constants.swift b/ManicEmu/ManicEmu/Sources/Base/Constants.swiftindex 4c73829b..ff842140 100644--- a/ManicEmu/ManicEmu/Sources/Base/Constants.swift+++ b/ManicEmu/ManicEmu/Sources/Base/Constants.swift@@ -9,6 +9,7 @@import UIKitimport RealmSwift+import ProHUDextension _R {var Size: _Size.Type { _Size.self }@@ -29,20 +30,19 @@ extension _R {extension _R {struct _Size {//系统常用尺寸- static var WindowSize: CGSize { UIWindow.applicationWindow?.bounds.size ?? .zero }- static var WindowWidth: CGFloat { WindowSize.width }- static var WindowHeight: CGFloat { WindowSize.height }- static var SafeArea: UIEdgeInsets { UIWindow.applicationWindow?.safeAreaInsets ?? .zero}- static var TopWindowSafeArea: UIEdgeInsets { UIWindow.topWindow?.safeAreaInsets ?? .zero}- static var PresentationTop: CGFloat { UIDevice.isPhone ? (UIDevice.hasNotch ? 69 : 40) : 0 }+ static var ApplicationWindowSize: CGSize { UIWindow.applicationWindow?.bounds.size ?? .zero }+ static var PresentationTop: CGFloat { UIDevice.isPhone ? ((UIDevice.hasNotch || UIDevice.hasDynamicIsland) ? 69 : 40) : 0 }///符号图标size 18static let SymbolSize = 18.0///HomeTabBarSize 300x60static let HomeTabBarSize = CGSize(width: 300, height: ItemHeightLarge)- /// 侧边视图宽度- static let SideMenuWidth = UIDevice.isPhone ? WindowSize.minDimension * 0.874 : 300++ static func SideMenuWidth(window: UIWindow?) -> CGFloat {+ let windowSize = (window ?? UIWindow.applicationWindow)?.size ?? R.Size.ApplicationWindowSize+ return UIDevice.isPhone ? windowSize.minDimension * 0.874 : 300+ }/// 游戏封面宽高比 默认1:1static func GameCoverRatio(gameType: GameType, ignoreForceSquare: Bool = false) -> CGFloat {if R.Style.GameCoverForceSquare && !ignoreForceSquare {@@ -102,15 +102,15 @@ extension _R {static let GameNameMaxCount = 255///CollectionView的top缩进- static var ContentInsetTop: CGFloat {- let safeArea = R.Size.SafeArea- return safeArea.top > 0 ? safeArea.top : R.Size.ContentSpaceLarge+ static func ContentInsetTop(window: UIWindow?) -> CGFloat {+ let safeAreaTop = (window ?? UIWindow.applicationWindow)?.safeAreaInsets.top ?? 0+ return safeAreaTop > 0 ? safeAreaTop : R.Size.ContentSpaceLarge}///CollectionView的bottom缩进- static var ContentInsetBottom: CGFloat {- let safeArea = R.Size.SafeArea- return safeArea.bottom > 0 ? safeArea.bottom : R.Size.ContentSpaceLarge+ static func ContentInsetBottom(window: UIWindow?) -> CGFloat {+ let safeAreaBottom = (window ?? UIWindow.applicationWindow)?.safeAreaInsets.bottom ?? 0+ return safeAreaBottom > 0 ? safeAreaBottom : R.Size.ContentSpaceLarge}///苹果图标默认尺寸@@ -236,22 +236,26 @@ extension _R {//MARK: - Sheetstatic var SheetWindowMaxSize: CGSize {+ let window = proHUDWindow()+ let windowSize = window?.size ?? R.Size.ApplicationWindowSizeif UIDevice.isPhone {- if UIDevice.isLandscape {- return CGSize(width: WindowHeight, height: WindowHeight - SafeArea.vertical)+ if windowSize.IsRelativelyWideRectangle {+ return CGSize(width: windowSize.height, height: windowSize.height - (window?.safeAreaInsets.vertical ?? 0))} else {- return CGSize(width: WindowWidth, height: WindowHeight - PresentationTop)+ return CGSize(width: windowSize.width, height: windowSize.height - PresentationTop)}} else if UIDevice.isPad {- if UIDevice.isLandscape {- let height = WindowHeight * 0.9- return CGSize(width: height*9/16, height: height)+ if windowSize.IsRelativelyWideRectangle {+ let height = windowSize.height * 0.9+ let width = min(max(height*9/16, 375), windowSize.width * 0.9)+ return CGSize(width: width, height: height)} else {- let width = WindowWidth*(UIDevice.isPadMini ? 0.65 : 0.5)- return CGSize(width: width, height: width*16/9)+ let width = max(windowSize.width*(UIDevice.isPadMini ? 0.65 : 0.5), 375)+ let height = min(width*16/9, windowSize.height*0.9)+ return CGSize(width: width, height: height)}}- return R.Size.WindowSize+ return R.Size.ApplicationWindowSize}static var SheetWindowMinSize: CGSize {@@ -260,7 +264,8 @@ extension _R {}static var SheetFullScreenForIpadLandscape: CGSize {- let width = WindowWidth*0.8+ let windowSize = proHUDWindow()?.size ?? R.Size.ApplicationWindowSize+ let width = windowSize.width*(UIDevice.isLandscape ? 0.8 : 0.9)return CGSize(width: width, height: width*9/16)}@@ -295,7 +300,9 @@ extension _R {static let ItemHeightMicro = 30.0//MARK: Others- static var PageBackgroundMaskHeight: CGFloat { ContentInsetTop + ItemHeightMedium }+ static func PageBackgroundMaskHeight(window: UIWindow?) -> CGFloat {+ ContentInsetTop(window: window) + ItemHeightMedium+ }static let GameInfoGameOptionsTopInsets = 380.0@@ -303,8 +310,10 @@ extension _R {static var PreferredContentSize: CGSize {var sheetSize = SheetWindowMaxSize- if UIDevice.isLandscape {- sheetSize.height = WindowHeight * 0.79+ let window = proHUDWindow()+ let windowSize = window?.size ?? R.Size.ApplicationWindowSize+ if windowSize.IsRelativelyWideRectangle {+ sheetSize.height = windowSize.height * 0.79}return sheetSize}diff --git a/ManicEmu/ManicEmu/Sources/Base/Functions.swift b/ManicEmu/ManicEmu/Sources/Base/Functions.swiftindex c9e6597b..aa8920f8 100644--- a/ManicEmu/ManicEmu/Sources/Base/Functions.swift+++ b/ManicEmu/ManicEmu/Sources/Base/Functions.swift@@ -10,14 +10,16 @@ func objectInfo(_ object: AnyObject) -> String {"\(NSStringFromClass(type(of: object))): \(Unmanaged.passUnretained(object).toOpaque())"}-func topViewController(appController: Bool = false) -> UIViewController? {- if appController {- //如果设置为true则只找自己应用的window 弹窗那些window就不去找了- if let vc = topViewController(rootViewController: ApplicationSceneDelegate.applicationWindow?.rootViewController) {- return vc- }- } else if let window = UIWindow.topWindow,- let vc = topViewController(rootViewController: window.rootViewController) {+func topApplicationViewController() -> UIViewController? {+ if let vc = topViewController(rootViewController: UIWindow.applicationWindow?.rootViewController) {+ return vc+ }+ return nil+}++func topViewController(in scene: UIWindowScene?) -> UIViewController? {+ if let window = UIWindow.topWindow(in: scene),+ let vc = topViewController(rootViewController: window.rootViewController) {return vc}return nildiff --git a/ManicEmu/ManicEmu/Sources/Business/CheatCode/Views/AddCheatCodeView.swift b/ManicEmu/ManicEmu/Sources/Business/CheatCode/Views/AddCheatCodeView.swiftindex a99a7579..41d11548 100644--- a/ManicEmu/ManicEmu/Sources/Business/CheatCode/Views/AddCheatCodeView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/CheatCode/Views/AddCheatCodeView.swift@@ -39,7 +39,7 @@ class AddCheatCodeView: BaseView {view.dataSource = selfview.delegate = selfview.isFocusable = true- view.contentInset = .insets(bottom: R.Size.ContentInsetBottom + R.Size.ButtonExtraLarge + R.Size.ContentSpaceMedium)+ view.contentInset = .insets(bottom: R.Size.ContentInsetBottom(window: hostingWindow) + R.Size.ButtonExtraLarge + R.Size.ContentSpaceMedium)return view}()@@ -47,7 +47,7 @@ class AddCheatCodeView: BaseView {let view = UIView()view.addSubview(saveButton)saveButton.snp.makeConstraints { make in- if UIDevice.isPad || (UIDevice.isPhone && UIDevice.isLandscape) {+ if UIDevice.isPad || (UIDevice.isPhone && proHUDLayoutStyle() == .landscape) {make.width.equalTo(R.Size.ButtonMaxWidth)make.centerX.equalToSuperview()} else {diff --git a/ManicEmu/ManicEmu/Sources/Business/CheatCode/Views/CheatCodeListView.swift b/ManicEmu/ManicEmu/Sources/Business/CheatCode/Views/CheatCodeListView.swiftindex 7c59cbfb..7bfee818 100644--- a/ManicEmu/ManicEmu/Sources/Business/CheatCode/Views/CheatCodeListView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/CheatCode/Views/CheatCodeListView.swift@@ -205,10 +205,10 @@ class CheatCodeListView: BaseView {}ChevronSheetView.show(stringOptions: [R.string.localizable.tabbarTitleImport() + " \(cheatFileExtension)"], completion: { [weak self] optionIndex inguard let self, optionIndex != nil else { return }- FilesImporter.shared.presentImportController(supportedTypes: supportFileExtensions) { [weak self] urls in+ FilesImporter.shared.presentImportController(supportedTypes: supportFileExtensions, manualHandle: { [weak self] urls inguard let self else { return }self.parseImportCheatFiles(urls: urls)- }+ }, in: self.hostingWindowScene)})}} else if navigationValue.isTapEdit {@@ -271,7 +271,7 @@ class CheatCodeListView: BaseView {}} else if action.isBottom {if !PurchaseManager.isMember, datas.count >= R.Numbers.NonMemberCheatCodeCount {- topViewController()?.present(PurchaseViewController(), animated: true)+ topViewController(in: hostingWindowScene)?.present(PurchaseViewController(), animated: true)return}AddCheatCodeView.show(game: game)@@ -328,7 +328,7 @@ class CheatCodeListView: BaseView {return .init(icon: .image(R.image.cheatcode_empty_icon()),title: R.string.localizable.cheatCodeEmptyTitle(),detail: R.string.localizable.addCheatCodesDesc(),- layoutInsets: .insets(bottom: R.Size.ContentInsetBottom + R.Size.ButtonExtraLarge))+ layoutInsets: .insets(bottom: R.Size.ContentInsetBottom(window: hostingWindow) + R.Size.ButtonExtraLarge))}}diff --git a/ManicEmu/ManicEmu/Sources/Business/CheatCode/Views/GamehackingView.swift b/ManicEmu/ManicEmu/Sources/Business/CheatCode/Views/GamehackingView.swiftindex b8519ef5..da06087a 100644--- a/ManicEmu/ManicEmu/Sources/Business/CheatCode/Views/GamehackingView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/CheatCode/Views/GamehackingView.swift@@ -272,7 +272,7 @@ class GamehackingView: BaseView {view.allowsBackForwardNavigationGestures = falseview.isOpaque = falseview.backgroundColor = R.Color.BackgroundPrimary- view.scrollView.contentInset = .insets(bottom: R.Size.ContentInsetBottom + R.Size.ButtonExtraLarge + R.Size.ContentSpaceLarge)+ view.scrollView.contentInset = .insets(bottom: R.Size.ContentInsetBottom(window: hostingWindow) + R.Size.ButtonExtraLarge + R.Size.ContentSpaceLarge)return view}()@@ -309,13 +309,13 @@ class GamehackingView: BaseView {}addSubview(saveButton)saveButton.snp.makeConstraints { make in- if UIDevice.isPad || (UIDevice.isPhone && UIDevice.isLandscape) {+ if UIDevice.isPad || (UIDevice.isPhone && proHUDLayoutStyle() == .landscape) {make.width.equalTo(R.Size.ButtonMaxWidth)make.centerX.equalToSuperview()} else {make.leading.trailing.equalTo(safeAreaLayoutGuide).inset(R.Size.ContentSpaceHuge)}- make.bottom.equalToSuperview().inset(R.Size.ContentInsetBottom)+ make.bottom.equalToSuperview().inset(R.Size.ContentInsetBottom(window: hostingWindow))make.height.equalTo(R.Size.ButtonExtraLarge)}diff --git a/ManicEmu/ManicEmu/Sources/Business/Common/ViewControllers/BaseViewController.swift b/ManicEmu/ManicEmu/Sources/Business/Common/ViewControllers/BaseViewController.swiftindex 1e66adbc..5ac43d4d 100644--- a/ManicEmu/ManicEmu/Sources/Business/Common/ViewControllers/BaseViewController.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Common/ViewControllers/BaseViewController.swift@@ -92,7 +92,7 @@ class BaseViewController: UIViewController {view.insertSubview(maskView, at: 0)maskView.snp.makeConstraints { make inmake.leading.top.trailing.equalToSuperview()- make.height.equalTo(R.Size.PageBackgroundMaskHeight)+ make.height.equalTo(R.Size.PageBackgroundMaskHeight(window: hostingWindow))}maskView.isHidden = !enableBackgroundMaskbackgroundMaskView = maskView@@ -150,14 +150,14 @@ class BaseViewController: UIViewController {coordinator.animate(alongsideTransition: { [weak self] _ inself?.setPreferredContentSize()self?.backgroundMaskView?.snp.updateConstraints { make in- make.height.equalTo(R.Size.PageBackgroundMaskHeight)+ make.height.equalTo(R.Size.PageBackgroundMaskHeight(window: self?.hostingWindow))}})}override var prefersStatusBarHidden: Bool {if UIDevice.isPad {- return UIDevice.isLandscape+ return view.prefferedLayoutStyle == .landscape}return super.prefersStatusBarHidden}diff --git a/ManicEmu/ManicEmu/Sources/Business/Common/Views/ASListPageView.swift b/ManicEmu/ManicEmu/Sources/Business/Common/Views/ASListPageView.swiftindex 6b9f1f94..5ca65446 100644--- a/ManicEmu/ManicEmu/Sources/Business/Common/Views/ASListPageView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Common/Views/ASListPageView.swift@@ -120,9 +120,6 @@ class ASListPageView: BaseView {updateIndexView()}}- var contentsBottomInset: CGFloat {- listInsets.bottom + pageInsets.bottom + (enableSafeAreaBottomInsets ? R.Size.SafeArea.bottom : 0)- }//MARK: - Subviewsprivate var navigationView: ASNavigationView? = nil@@ -195,7 +192,7 @@ class ASListPageView: BaseView {self.listPage = listPageif listPage.sections.count == 0 {//Prevent constraint errors- super.init(frame: .init(origin: .zero, size: R.Size.WindowSize))+ super.init(frame: .init(origin: .zero, size: R.Size.ApplicationWindowSize))} else {super.init(frame: .zero)}@@ -215,7 +212,7 @@ extension ASListPageView {let containerWidth = env.container.effectiveContentSize.widthlet fallbackWidth = max(collectionView.bounds.width, bounds.width)let width = containerWidth > 1 ? containerWidth : fallbackWidth- let resolved = width > 1 ? width : R.Size.WindowWidth+ let resolved = width > 1 ? width : (hostingWindow?.width ?? R.Size.ApplicationWindowSize.width)return max(resolved - Self.sectionHorizontalInsets * 2 - Self.supplementaryHorizontalInsets * 2, 1)}@@ -520,9 +517,9 @@ extension ASListPageView {}if enableSafeAreaBottomInsets {- contentInset.bottom += R.Size.SafeArea.bottom+ contentInset.bottom += hostingWindow?.safeAreaInsets.bottom ?? 0if UIDevice.isSmallScreenPhone {- contentInset.bottom += R.Size.ContentInsetBottom+ contentInset.bottom += R.Size.ContentInsetBottom(window: hostingWindow)}}@@ -549,7 +546,7 @@ extension ASListPageView {if listPage.bottom != nil, let bottomButton, bottomButton.superview != nil {make.bottom.equalTo(bottomButton.snp.top).offset(-R.Size.ContentSpaceMedium)} else {- make.bottom.equalToSuperview().inset(contentsBottomInset)+ make.bottom.equalToSuperview().inset(contentsBottomInset(safeAreaBottom: self.hostingWindow?.safeAreaInsets.bottom ?? 0))}make.height.equalTo(Self.toolViewHeight)}@@ -590,7 +587,7 @@ extension ASListPageView {}view.snp.remakeConstraints { make in- if UIDevice.isPad || (UIDevice.isPhone && UIDevice.isLandscape) {+ if UIDevice.isPad || (UIDevice.isPhone && self.prefferedLayoutStyle == .landscape) {make.width.equalTo(R.Size.ButtonMaxWidth)make.centerX.equalToSuperview()} else {@@ -599,7 +596,7 @@ extension ASListPageView {make.leading.equalTo(enableSafeAreaLeftInsets ? safeAreaLayoutGuide : self).inset(leadingInset)make.trailing.equalTo(enableSafeAreaRightInsets ? safeAreaLayoutGuide : self).inset(trailingInset)}- make.bottom.equalToSuperview().inset(contentsBottomInset)+ make.bottom.equalToSuperview().inset(contentsBottomInset(safeAreaBottom: self.hostingWindow?.safeAreaInsets.bottom ?? 0))make.height.equalTo(Self.bottomButtonHeight)}@@ -676,7 +673,8 @@ extension ASListPageView {}static func calculateMinHeight(listPage: ASListPage,- containerWidth: CGFloat = R.Size.WindowSize.width) -> CGFloat {+ containerWindow: UIWindow?,+ containerWidth: CGFloat = R.Size.ApplicationWindowSize.width) -> CGFloat {var height = 0.0@@ -709,10 +707,11 @@ extension ASListPageView {}}- if fixContainerWidth == 0 && (section.header != nil || section.footer != nil) {- let countHorizontalSafeArea = containerWidth >= R.Size.WindowWidth - R.Size.SafeArea.horizontal- let leftSafeArea = (countHorizontalSafeArea && listPage.enableSafeAreaLeftInsets) ? R.Size.SafeArea.left : 0- let rightSafeArea = (countHorizontalSafeArea && listPage.enableSafeAreaRightInsets) ? R.Size.SafeArea.right : 0+ if fixContainerWidth == 0 && (section.header != nil || section.footer != nil),+ let window = containerWindow {+ let countHorizontalSafeArea = containerWidth >= window.width - window.safeAreaInsets.horizontal+ let leftSafeArea = (countHorizontalSafeArea && listPage.enableSafeAreaLeftInsets) ? window.safeAreaInsets.left : 0+ let rightSafeArea = (countHorizontalSafeArea && listPage.enableSafeAreaRightInsets) ? window.safeAreaInsets.right : 0fixContainerWidth = containerWidth -//This part isn’t quite right—if the header or footer has line breaks, the calculation might be off.leftSafeArea -@@ -743,14 +742,17 @@ extension ASListPageView {height += listPage.listInsets.bottom- if height >= R.Size.WindowHeight - R.Size.SafeArea.vertical, listPage.enableSafeAreaTopInsets {- height += R.Size.SafeArea.top+ if let window = containerWindow,+ height >= window.height - window.safeAreaInsets.vertical,+ listPage.enableSafeAreaTopInsets {+ height += window.safeAreaInsets.top}- if listPage.enableSafeAreaBottomInsets {- height += R.Size.SafeArea.bottom+ if listPage.enableSafeAreaBottomInsets,+ let window = containerWindow {+ height += window.safeAreaInsets.bottomif UIDevice.isSmallScreenPhone {- height += R.Size.ContentInsetBottom+ height += R.Size.ContentInsetBottom(window: containerWindow)}}@@ -867,6 +869,10 @@ extension ASListPageView {}indexView?.reloadData()}++ func contentsBottomInset(safeAreaBottom: CGFloat) -> CGFloat {+ listInsets.bottom + pageInsets.bottom + (enableSafeAreaBottomInsets ? safeAreaBottom : 0)+ }}//MARK: - UICollectionViewDataSourcediff --git a/ManicEmu/ManicEmu/Sources/Business/Common/Views/ASSheetView.swift b/ManicEmu/ManicEmu/Sources/Business/Common/Views/ASSheetView.swiftindex 8f72d7b9..28026263 100644--- a/ManicEmu/ManicEmu/Sources/Business/Common/Views/ASSheetView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Common/Views/ASSheetView.swift@@ -62,7 +62,7 @@ class ASSheetView: BaseView {let containerView = UIView()var roundCorner: UIRectCorner {- (UIDevice.isPad || UIDevice.isLandscape || PlayViewController.menuInsets != nil) ? .allCorners : [.topLeft, .topRight]+ (UIDevice.isPad || getLayoutStyle() == .landscape || PlayViewController.menuInsets != nil) ? .allCorners : [.topLeft, .topRight]}let contentView = RoundAndBorderView(roundCorner: roundCorner, borderWidth: 1.5)contentView.backgroundColor = R.Color.BackgroundPrimary@@ -174,10 +174,10 @@ class ASSheetView: BaseView {//Other style configurations for the sheetfunc updateCardSize(config: SheetConfiguration) {- if sheetData.fullScreenForLandscape, UIDevice.isLandscape {+ if sheetData.fullScreenForLandscape, getLayoutStyle() == .landscape {if UIDevice.isPhone {- config.cardMaxWidth = R.Size.WindowWidth- config.cardMaxHeight = R.Size.WindowHeight+ config.cardMaxWidth = proHUDWindow()?.width+ config.cardMaxHeight = proHUDWindow()?.height} else {config.cardMaxWidth = R.Size.SheetFullScreenForIpadLandscape.widthconfig.cardMaxHeight = R.Size.SheetFullScreenForIpadLandscape.height@@ -217,7 +217,7 @@ class ASSheetView: BaseView {var didNotifyCovering = falsefunc isCoveringLandscapeBackground() -> Bool {- sheetData.fullScreenForLandscape && UIDevice.isPhone && UIDevice.isLandscape+ sheetData.fullScreenForLandscape && UIDevice.isPhone && getLayoutStyle() == .landscape}func syncLandscapeBackgroundCovering() {let covering = isCoveringLandscapeBackground()@@ -255,11 +255,12 @@ class ASSheetView: BaseView {//Set view constraintsfunc updateContentViewConstraints() {- if sheetData.fullScreenForLandscape, UIDevice.isLandscape {+ if sheetData.fullScreenForLandscape, getLayoutStyle() == .landscape {contentView.snp.remakeConstraints { make inmake.edges.equalToSuperview()if UIDevice.isPhone {- make.height.equalTo(R.Size.WindowHeight)+ let windowHeight = (proHUDWindow()?.height) ?? R.Size.ApplicationWindowSize.height+ make.height.equalTo(windowHeight)} else {make.height.equalTo(R.Size.SheetFullScreenForIpadLandscape.height)}@@ -293,9 +294,9 @@ class ASSheetView: BaseView {sheetView.config.viewWillTransitionUpdate = { [weak sheetView] _, reloadHUD inguard let sheetView, let cardMaxHeight = sheetView.config.cardMaxHeight else { return }let heightWillSet: CGFloat- if sheetData.fullScreenForLandscape, UIDevice.isLandscape {+ if sheetData.fullScreenForLandscape, getLayoutStyle() == .landscape {if UIDevice.isPhone {- heightWillSet = R.Size.WindowHeight+ heightWillSet = (proHUDWindow()?.height) ?? R.Size.ApplicationWindowSize.height} else {heightWillSet = R.Size.SheetFullScreenForIpadLandscape.height}@@ -324,12 +325,25 @@ class ASSheetView: BaseView {}}+ private static func getLayoutStyle() -> UIView.LayoutStyle {+ if let w = proHUDWindow(), w.size != .zero {+ if w.size.IsRelativelyWideRectangle {+ return .landscape+ } else {+ return .portrait+ }+ } else {+ return UIDevice.isLandscape ? .landscape : .portrait+ }+ }+private static func calculateHeight(sheetData: ASSheet) -> CGFloat? {let containerWidth = R.Size.SheetWindowMaxSize.widthswitch sheetData.style {case .listPage(let listPage):return ASListPageView.calculateMinHeight(listPage: listPage,+ containerWindow: proHUDWindow(),containerWidth: containerWidth)case .options(let icon, let title, let detail, let options, let selectedIndexPath, let cancelEnable, let optionsType):@@ -341,6 +355,7 @@ class ASSheetView: BaseView {cancelEnable: cancelEnable,optionsType: optionsType),enableGrabber: sheetData.enableGrabber),+ containerWindow: proHUDWindow(),containerWidth: containerWidth)case .simpleList(let icon, let title, let detail, let options, let cancelEnable):@@ -350,6 +365,7 @@ class ASSheetView: BaseView {options: options,cancelEnable: cancelEnable),enableGrabber: sheetData.enableGrabber),+ containerWindow: proHUDWindow(),containerWidth: containerWidth)case .updation(_, let detail):@@ -777,7 +793,7 @@ extension ASSheetView {func viewAlongsideTransition() {bottomView?.snp.updateConstraints { make in- make.bottom.equalToSuperview().inset(R.Size.ContentInsetBottom)+ make.bottom.equalToSuperview().inset(R.Size.ContentInsetBottom(window: hostingWindow))}}}@@ -874,7 +890,7 @@ extension ASSheetView {make.leading.equalToSuperview()make.trailing.equalTo(verticalLine.snp.leading)}- make.bottom.equalToSuperview().inset(R.Size.ContentInsetBottom)+ make.bottom.equalToSuperview().inset(R.Size.ContentInsetBottom(window: hostingWindow))make.height.equalTo(R.Size.ButtonExtraLarge)}@@ -1033,7 +1049,7 @@ extension ASSheetView {addSubview(stepView)stepView.snp.makeConstraints { make inmake.centerX.equalToSuperview()- make.bottom.equalToSuperview().inset(R.Size.ContentInsetBottom)+ make.bottom.equalToSuperview().inset(R.Size.ContentInsetBottom(window: hostingWindow))make.height.equalTo(R.Size.ButtonSmall)if let detailLabel {make.top.equalTo(detailLabel.snp.bottom).offset(R.Size.ContentSpaceLarge)@@ -1113,7 +1129,7 @@ extension ASSheetView {} else {make.top.equalToSuperview().offset(R.Size.ItemHeightMedium)}- make.bottom.equalToSuperview().inset(R.Size.ContentInsetBottom)+ make.bottom.equalToSuperview().inset(R.Size.ContentInsetBottom(window: hostingWindow))make.height.equalTo(300).priority(.high)}pickerView.addComponents([datas]) { [weak self] element, component, row indiff --git a/ManicEmu/ManicEmu/Sources/Business/Common/Views/ASWebView.swift b/ManicEmu/ManicEmu/Sources/Business/Common/Views/ASWebView.swiftindex 1d324a06..47784930 100644--- a/ManicEmu/ManicEmu/Sources/Business/Common/Views/ASWebView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Common/Views/ASWebView.swift@@ -65,7 +65,7 @@ class ASWebView: BaseView {view.isOpaque = falseview.backgroundColor = R.Color.BackgroundPrimaryview.scrollView.backgroundColor = R.Color.BackgroundPrimary- view.scrollView.contentInset = .insets(bottom: R.Size.ContentInsetBottom)+ view.scrollView.contentInset = .insets(bottom: R.Size.ContentInsetBottom(window: hostingWindow))return view}()@@ -187,12 +187,12 @@ extension ASWebView: WKNavigationDelegate {let mailController = MFMailComposeViewController()mailController.setToRecipients([R.Strings.SupportEmail])mailController.mailComposeDelegate = self- topViewController(appController: true)?.present(mailController, animated: true)+ topApplicationViewController()?.present(mailController, animated: true)} else {let mailController = MFMailComposeViewController()mailController.setToRecipients([url.string.replacingOccurrences(of: "mailto:", with: "")])mailController.mailComposeDelegate = self- topViewController(appController: true)?.present(mailController, animated: true)+ topApplicationViewController()?.present(mailController, animated: true)}} else {UIView.makeToast(message: R.string.localizable.noEmailSetting())diff --git a/ManicEmu/ManicEmu/Sources/Business/Common/Views/CheersView.swift b/ManicEmu/ManicEmu/Sources/Business/Common/Views/CheersView.swiftindex 7e176f5d..25a41d01 100644--- a/ManicEmu/ManicEmu/Sources/Business/Common/Views/CheersView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Common/Views/CheersView.swift@@ -14,8 +14,8 @@ import SwiftUIstruct CheersView: View {- static func makePurchaseCheers() {- if let window = UIWindow.topWindow {+ static func makePurchaseCheers(in scene: UIWindowScene?) {+ if let window = UIWindow.topWindow(in: scene) {let vc = UIHostingController(rootView: CheersView().edgesIgnoringSafeArea(.all))if let cheersView = vc.view {@@ -46,7 +46,8 @@ struct CheersView: View {make.edges.equalToSuperview()}- DispatchQueue.main.asyncAfter(delay: 2) {+ DispatchQueue.main.asyncAfter(delay: 2) { [weak container] in+ guard let container else { return }container.addTapGesture { [weak container] gesture inUIView.normalAnimate(animations: {memberView.alpha = 0@@ -65,7 +66,7 @@ struct CheersView: View {$0.isHidden == false &&$0.rootViewController != nil &&(String(describing: type(of: $0)) == "SheetWindow" || String(describing: type(of: $0)) == "AlertWindow" || $0.windowLevel == .normal)- })) : ApplicationSceneDelegate.applicationWindow+ })) : UIWindow.applicationWindowif let window {let vc = UIHostingController(rootView: CheersView().edgesIgnoringSafeArea(.all))@@ -101,15 +102,15 @@ struct CheersView: View {var body: some View {Button(" "){}- .confettiCannon(trigger: $trigger, num: 100, confettiSize: 22.5, rainHeight: R.Size.WindowHeight, openingAngle: Angle(degrees: 0), closingAngle: Angle(degrees: 180), radius: customRadius)+ .confettiCannon(trigger: $trigger, num: 100, confettiSize: 22.5, rainHeight: R.Size.ApplicationWindowSize.height, openingAngle: Angle(degrees: 0), closingAngle: Angle(degrees: 180), radius: customRadius).onAppear {trigger += 1}}private var customRadius: CGFloat {- var radius = R.Size.WindowWidth/(UIDevice.isPad ? 2 : 1)- if UIDevice.isPhone, UIDevice.isLandscape {+ var radius = R.Size.ApplicationWindowSize.width/(UIDevice.isPad ? 2 : 1)+ if UIDevice.isPhone, R.Size.ApplicationWindowSize.IsRelativelyWideRectangle {radius = radius/2}return radiusdiff --git a/ManicEmu/ManicEmu/Sources/Business/Common/Views/FileBrowserView.swift b/ManicEmu/ManicEmu/Sources/Business/Common/Views/FileBrowserView.swiftindex c5fbfd9e..2d883ec1 100644--- a/ManicEmu/ManicEmu/Sources/Business/Common/Views/FileBrowserView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Common/Views/FileBrowserView.swift@@ -199,10 +199,10 @@ class FileBrowserView: BaseView {hide()}} else if let index = navigationValue.tapToolsValue {- if index == 0 {+ if index == 0 && currentPageItems.filter({ !$0.isDirectory }).count > 0 {//edit modeisEditMode = true- } else if index == 1 {+ } else if index == 1 || (index == 0 && currentPageItems.filter({ !$0.isDirectory }).count == 0) {//download managerDownloadManageView.show()}@@ -288,13 +288,22 @@ class FileBrowserView: BaseView {title = rootNavigationTitle ?? "/"}+ let tools: [ASIcon]+ if currentPageItems.filter({ !$0.isDirectory }).count > 0 {+ tools = [+ .symbolImage(R.image.selectedit_iconSymbols()),+ .symbolImage(R.image.cloudDownload_iconSymbols(), animated: DownloadManager.shared.hasDownloadTask)+ ]+ } else {+ tools = [+ .symbolImage(R.image.cloudDownload_iconSymbols(), animated: DownloadManager.shared.hasDownloadTask)+ ]+ }+var navigation = ASListPage.Navigation.defaultNavigation(title: title,titleLineBreakMode: .byTruncatingHead,titleIcon: icon,- tools: [- .symbolImage(R.image.selectedit_iconSymbols()),- .symbolImage(R.image.cloudDownload_iconSymbols(), animated: DownloadManager.shared.hasDownloadTask)- ])+ tools: tools)if pages.count > 1 {navigation.enableTitleInteractive = true}@@ -376,7 +385,7 @@ class FileBrowserView: BaseView {let errorsString = falures.reduce("") { ($0.isEmpty ? $0 : "\n") + $1 }error.append(ImportError.downloadError(filenames: errorsString))}- FilesImporter.importFiles(urls: urls, preErrors: error)+ FilesImporter.importFiles(urls: urls, preErrors: error, in: self.hostingWindowScene)}return}diff --git a/ManicEmu/ManicEmu/Sources/Business/Common/Views/LimitedTextInputView.swift b/ManicEmu/ManicEmu/Sources/Business/Common/Views/LimitedTextInputView.swiftindex ec7f01d4..1017dfee 100644--- a/ManicEmu/ManicEmu/Sources/Business/Common/Views/LimitedTextInputView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Common/Views/LimitedTextInputView.swift@@ -203,9 +203,9 @@ struct LimitedTextInputView {}}- alert.onViewDidAppear { alert in+ alert.onViewDidAppear { [weak inputView] alert inalert.pushOverlayFocusContext { context in- context.cancelHandler = { [weak inputView] in+ context.cancelHandler = {if inputView?.isFirstResponder == true {inputView?.resignFirstResponder()return true@@ -224,7 +224,7 @@ struct LimitedTextInputView {width = 375} else {width = R.Size.SheetWindowMinSize.width- if UIDevice.isPortrait {+ if proHUDLayoutStyle() == .portrait {width -= R.Size.ContentSpaceHuge*2}}diff --git a/ManicEmu/ManicEmu/Sources/Business/Common/Views/RomPatcherView.swift b/ManicEmu/ManicEmu/Sources/Business/Common/Views/RomPatcherView.swiftindex c28a63b3..876b2b0f 100644--- a/ManicEmu/ManicEmu/Sources/Business/Common/Views/RomPatcherView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Common/Views/RomPatcherView.swift@@ -215,7 +215,7 @@ class RomPatcherView: BaseView {view.isOpaque = falseview.backgroundColor = R.Color.BackgroundPrimaryview.scrollView.backgroundColor = R.Color.BackgroundPrimary- view.scrollView.contentInset = .insets(bottom: R.Size.ContentInsetBottom)+ view.scrollView.contentInset = .insets(bottom: R.Size.ContentInsetBottom(window: hostingWindow))return view}()@@ -336,10 +336,10 @@ extension RomPatcherView: WKScriptMessageHandler {DispatchQueue.main.async {UIView.makeAlert(title: R.string.localizable.downloadCompletion(), detail: fileName, cancelTitle: R.string.localizable.gamesShareRom(), confirmTitle: isPatch ? nil : R.string.localizable.m3uFileImport(), cancelAction: {//分享- ShareManager.shareFile(fileUrl: fileUrl)+ ShareManager.shareFile(fileUrl: fileUrl, in: self.hostingWindowScene)}, confirmAction: {//导入- FilesImporter.importFiles(urls: [fileUrl])+ FilesImporter.importFiles(urls: [fileUrl], in: self.hostingWindowScene)})}} catch {diff --git a/ManicEmu/ManicEmu/Sources/Business/Controllers/Views/ControllerMappingView.swift b/ManicEmu/ManicEmu/Sources/Business/Controllers/Views/ControllerMappingView.swiftindex 3c57c38b..65800903 100644--- a/ManicEmu/ManicEmu/Sources/Business/Controllers/Views/ControllerMappingView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Controllers/Views/ControllerMappingView.swift@@ -205,7 +205,7 @@ class ControllerMappingView: BaseView {addSubview(navigationView)navigationView.snp.makeConstraints { make in- make.top.equalToSuperview().offset(R.Size.SafeArea.top)+ make.top.equalTo(safeAreaLayoutGuide)make.leading.trailing.equalTo(safeAreaLayoutGuide).inset(R.Size.ContentSpaceHuge)make.height.equalTo(R.Size.NavigationHeight)}@@ -220,7 +220,8 @@ class ControllerMappingView: BaseView {private func updateDatas() {if let controlerSkin = ControllerSkin.standardControllerSkin(for: gameType),- let frames = controlerSkin.getFrames() {+ let hostingWindow,+ let frames = controlerSkin.getFrames(window: hostingWindow) {controllerView.controllerSkin = controlerSkincontrollerView.snp.remakeConstraints { make inmake.center.equalToSuperview()@@ -432,7 +433,7 @@ class ControllerMappingView: BaseView {private func setupMappingBubble() {inputPopupView.subviews.forEach { $0.removeFromSuperview() }- let traits = ControllerSkin.Traits.defaults(for: UIWindow.applicationWindow ?? UIWindow(frame: .init(origin: .zero, size: R.Size.WindowSize)))+ let traits = ControllerSkin.Traits.defaults(for: UIWindow.applicationWindow ?? UIWindow(frame: .init(origin: .zero, size: R.Size.ApplicationWindowSize)))if let items = controllerView.controllerSkin?.items(for: traits) {for item in items {let scaledFrame = item.frame.applying(.init(scaleX: inputPopupView.width, y: inputPopupView.height))diff --git a/ManicEmu/ManicEmu/Sources/Business/Controllers/Views/ControllersSettingView.swift b/ManicEmu/ManicEmu/Sources/Business/Controllers/Views/ControllersSettingView.swiftindex 3d2d600d..e941fc6f 100644--- a/ManicEmu/ManicEmu/Sources/Business/Controllers/Views/ControllersSettingView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Controllers/Views/ControllersSettingView.swift@@ -167,7 +167,7 @@ class ControllersSettingView: BaseView {//change player indexif !PurchaseManager.isMember {- topViewController()?.present(PurchaseViewController(featuresType: .controler), animated: true)+ topViewController(in: self.hostingWindowScene)?.present(PurchaseViewController(featuresType: .controler), animated: true)return}@@ -192,7 +192,7 @@ class ControllersSettingView: BaseView {} else {vc = .init(gameType: gameType, controller: controller)}- topViewController()?.present(vc, animated: true)+ topViewController(in: hostingWindowScene)?.present(vc, animated: true)}}}@@ -210,7 +210,7 @@ class ControllersSettingView: BaseView {return ASListPage(navigation: navigation,sections: getSections(),backgroundColor: .clear,- pageInsets: .insets(top: asSideMenu ? R.Size.ContentInsetTop : R.Size.SheetGrabberTopInset),+ pageInsets: .insets(top: asSideMenu ? R.Size.ContentInsetTop(window: hostingWindow) : R.Size.SheetGrabberTopInset),enableSafeAreaLeftInsets: true,enableSafeAreaRightInsets: true)}@@ -245,8 +245,8 @@ class ControllersSettingView: BaseView {func updateTopInsets() {guard asSideMenu else { return }- guard listPageView.pageInsets.top != R.Size.ContentInsetTop else { return }- listPageView.pageInsets = .insets(top: R.Size.ContentInsetTop)+ guard listPageView.pageInsets.top != R.Size.ContentInsetTop(window: hostingWindow) else { return }+ listPageView.pageInsets = .insets(top: R.Size.ContentInsetTop(window: hostingWindow))}}diff --git a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/CitraAdvancedSettingView.swift b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/CitraAdvancedSettingView.swiftindex 7f398b86..5b4a1067 100644--- a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/CitraAdvancedSettingView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/CitraAdvancedSettingView.swift@@ -319,11 +319,11 @@ class CitraAdvancedSettingView: BaseView {private func shareConfig() {saveIfNeeded()- ShareManager.shareFile(fileUrl: URL(fileURLWithPath: R.Path.CitraConfig))+ ShareManager.shareFile(fileUrl: URL(fileURLWithPath: R.Path.CitraConfig), in: hostingWindowScene)}private func importConfig() {- FilesImporter.shared.presentImportController(supportedTypes: UTType.configTypes, allowsMultipleSelection: false) { [weak self] urls in+ FilesImporter.shared.presentImportController(supportedTypes: UTType.configTypes, allowsMultipleSelection: false, manualHandle: { [weak self] urls inguard let self, let url = urls.first else { return }do {try FileManager.safeCopyItem(at: url,@@ -334,7 +334,7 @@ class CitraAdvancedSettingView: BaseView {} catch {UIView.makeToast(message: R.string.localizable.readConfigFileFailed())}- }+ }, in: hostingWindowScene)}//MARK: - Configuration read/writediff --git a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameCoverModifyView.swift b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameCoverModifyView.swiftindex 4bcb8b1f..7aa7584d 100644--- a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameCoverModifyView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameCoverModifyView.swift@@ -61,7 +61,7 @@ class GameCoverModifyView: BaseView {private func makeListPage() -> ASListPage {// 横屏时 WindowSize.width 会变成长边,不能拿来当容器宽;未布局时用短边兜底。- let availableWidth = bounds.width > 0 ? bounds.width : R.Size.WindowSize.minDimension+ let availableWidth = bounds.width > 0 ? bounds.width : R.Size.ApplicationWindowSize.minDimensionreturn ASListPage(navigation: .defaultNavigation(title: R.string.localizable.gamesModifyCover(),titleIcon: .symbolImage(R.image.cover_iconSymbols())),@@ -125,7 +125,9 @@ class GameCoverModifyView: BaseView {sources.append(.delete)}- ImageFetcher.showCommonFetcher(sources: sources) { [weak self] image, source in+ ImageFetcher.showCommonFetcher(sources: sources,+ in: hostingWindowScene,+ completion: { [weak self] image, source inguard let self else { return }if case .delete = source {self.removeImage(for: kind)@@ -133,7 +135,7 @@ class GameCoverModifyView: BaseView {}guard let image else { return }self.persist(image: image, for: kind)- }+ })}private func persist(image: UIImage, for kind: CoverSlotKind) {@@ -223,8 +225,8 @@ private enum CoverSlotKind {case .banner:let width = max(availableWidth - inset, 1)// 始终按设备横向屏幕尺寸(长边 x 短边),不随当前方向宽高互换。- let landscapeWidth = R.Size.WindowSize.maxDimension- let landscapeHeight = R.Size.WindowSize.minDimension+ let landscapeWidth = R.Size.ApplicationWindowSize.maxDimension+ let landscapeHeight = R.Size.ApplicationWindowSize.minDimensionlet landscapeAspect = landscapeWidth / max(landscapeHeight, 1)return CGSize(width: width, height: width / max(landscapeAspect, 0.01))}diff --git a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameCoverScrapingView.swift b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameCoverScrapingView.swiftindex 809faae7..9f4f755d 100644--- a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameCoverScrapingView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameCoverScrapingView.swift@@ -62,8 +62,8 @@ class GameCoverScrapingView: BaseView {}}- convenience init(showClose: Bool) {- self.init(parameters: showClose)!+ convenience init(games: [Game], showClose: Bool) {+ self.init(parameters: games, showClose)!}@MainActor required init?(coder: NSCoder) {@@ -87,12 +87,15 @@ class GameCoverScrapingView: BaseView {)navigation.enableClose = showClose+ let listInsetBottom = (UIDevice.isPad && !showClose) ? R.Size.ContentInsetBottom(window: hostingWindow) + R.Size.HomeTabBarSize.height + R.Size.ContentSpaceMedium : 0+return ASListPage(navigation: navigation,sections: getSections(),bottom: getBottom(),backgroundColor: .clear,- pageInsets: .insets(top: R.Size.SheetGrabberTopInset)+ listInsets: .insets(bottom: listInsetBottom),+ pageInsets: .insets(top: showClose ? R.Size.SheetGrabberTopInset : R.Size.ContentInsetTop(window: hostingWindow)))}diff --git a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameInfoCoverView.swift b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameInfoCoverView.swiftindex 7da4a051..462c3794 100644--- a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameInfoCoverView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameInfoCoverView.swift@@ -102,9 +102,9 @@ class GameInfoCoverView: BaseView {private func updateCoverContainerViewConstraints() {coverContainerView.snp.remakeConstraints { make in- make.size.equalTo(UIDevice.isLandscape ? CoverImageSize.applying(.init(scaleX: 0.8, y: 0.8)) : CoverImageSize)+ make.size.equalTo(proHUDLayoutStyle() == .landscape ? CoverImageSize.applying(.init(scaleX: 0.8, y: 0.8)) : CoverImageSize)make.centerX.equalToSuperview()- make.centerY.equalToSuperview().offset(UIDevice.isLandscape ? -R.Size.ItemHeightLarge : -R.Size.ItemHeightMicro)+ make.centerY.equalToSuperview().offset(proHUDLayoutStyle() == .landscape ? -R.Size.ItemHeightLarge : -R.Size.ItemHeightMicro)}}}diff --git a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameInfoDetailView.swift b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameInfoDetailView.swiftindex 30bda4ff..679be79f 100644--- a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameInfoDetailView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameInfoDetailView.swift@@ -55,7 +55,7 @@ class GameInfoDetailView: BaseView {view.enableFocusEffects = falseview.didTapButton = { [weak self] inguard let self = self else { return }- self.game.handleTapAction(forceQuick: true)+ self.game.handleTapAction(forceQuick: true, in: self.hostingWindowScene)}view.isAccessibilityElement = trueview.accessibilityLabel = R.string.localizable.startGameTitle()@@ -81,7 +81,7 @@ class GameInfoDetailView: BaseView {confirmAction: { [weak self] inguard let self else { return }self.game.safeMode = true- self.game.handleTapAction(forceQuick: true)+ self.game.handleTapAction(forceQuick: true, in: self.hostingWindowScene)})}view.isAccessibilityElement = truediff --git a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameInfoNavigationView.swift b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameInfoNavigationView.swiftindex fe0af006..e66f8d1c 100644--- a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameInfoNavigationView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameInfoNavigationView.swift@@ -17,7 +17,7 @@ class GameInfoNavigationView: BaseView {var closeButton: ASButtonView = {let button = ASButton.smallIconButton(icon: .symbolImage(R.image.close_iconSymbols()),- background: UIDevice.isLandscape ? R.Color.BackgroundTertiary : R.Color.BackgroundSecondary).enableGlass(true)+ background: proHUDLayoutStyle() == .landscape ? R.Color.BackgroundTertiary : R.Color.BackgroundSecondary).enableGlass(true)let view = ASButtonView(button)return viewdiff --git a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameInfoView.swift b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameInfoView.swiftindex a991d688..3f5bdc8a 100644--- a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameInfoView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameInfoView.swift@@ -52,9 +52,9 @@ class GameInfoView: BaseView {private lazy var gameInfoDetailView: GameInfoDetailView = {let view = GameInfoDetailView(game: game)- let width = UIDevice.isPhone ? R.Size.WindowWidth : (UIDevice.isLandscape ? R.Size.SheetFullScreenForIpadLandscape.width : R.Size.SheetWindowMaxSize.width)+ let width = UIDevice.isPhone ? R.Size.ApplicationWindowSize.width : (proHUDLayoutStyle() == .landscape ? R.Size.SheetFullScreenForIpadLandscape.width : R.Size.SheetWindowMaxSize.width)view.frame = CGRect(origin: .zero,- size: CGSize(width: width/(UIDevice.isLandscape ? 2 : 1),+ size: CGSize(width: width/(proHUDLayoutStyle() == .landscape ? 2 : 1),height: gameInfoDetailHeight))return view}()@@ -70,7 +70,7 @@ class GameInfoView: BaseView {}view.didScroll = { [weak self] scrollView inguard let self else { return }- guard !UIDevice.isLandscape else { return }+ guard self.prefferedLayoutStyle == .portrait else { return }let contentOffsetY = scrollView.contentOffset.y + scrollView.adjustedContentInset.top//Make the gameInfoDetailView pin to the top of the gameOptionView content.if contentOffsetY >= scrollView.adjustedContentInset.top - self.gameInfoDetailHeight + R.Size.ContentSpaceSmall {@@ -110,7 +110,7 @@ class GameInfoView: BaseView {private let gameInfoDetailMaxY = 292.0private let gameInfoDetailHeight = 162.0private var gameOptionViewInsets: UIEdgeInsets {- .insets(top: UIDevice.isLandscape ? 0 : R.Size.GameInfoGameOptionsTopInsets,+ .insets(top: proHUDLayoutStyle() == .landscape ? 0 : R.Size.GameInfoGameOptionsTopInsets,bottom: R.Size.ContentSpaceLarge)}private var gameMetadataChange: Any? = nil@@ -232,7 +232,8 @@ class GameInfoView: BaseView {override func layoutSubviews() {super.layoutSubviews()guard width > 0 else { return }- if UIDevice.isLandscape {+ guard let window = hostingWindow else { return }+ if window.size.IsRelativelyWideRectangle {gameInfoDetailView.frame = CGRect(origin: CGPoint(x: 0, y: height - gameInfoDetailHeight),size: CGSize(width: width/2, height: gameInfoDetailHeight))} else {@@ -241,7 +242,8 @@ class GameInfoView: BaseView {}func updateViewsConstraints() {- if UIDevice.isLandscape {+ guard let window = proHUDWindow() else { return }+ if window.size.IsRelativelyWideRectangle {gameCoverView.snp.remakeConstraints { make inmake.leading.top.bottom.equalToSuperview()make.width.equalToSuperview().multipliedBy(0.5)@@ -299,6 +301,6 @@ extension GameInfoView: ViewTransition {navigationView.backgroundColor = .clearnavigationView.gameCover.alpha = 0gameInfoDetailView.backgroundColor = .clear- navigationView.closeButton.setBackgroundColor(UIDevice.isLandscape ? R.Color.BackgroundTertiary : R.Color.BackgroundSecondary)+ navigationView.closeButton.setBackgroundColor(proHUDLayoutStyle() == .landscape ? R.Color.BackgroundTertiary : R.Color.BackgroundSecondary)}}diff --git a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameSavePurchaseGuideView.swift b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameSavePurchaseGuideView.swiftindex 5139559b..5e4c6e85 100644--- a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameSavePurchaseGuideView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameSavePurchaseGuideView.swift@@ -12,8 +12,9 @@ class GameSavePurchaseGuideView: BaseView {super.init(frame: .zero)enablePressEffect = true- addTapGesture { gesture in- topViewController()?.present(PurchaseViewController(), animated: true)+ addTapGesture { [weak self] gesture in+ guard let self else { return }+ topViewController(in: self.hostingWindowScene)?.present(PurchaseViewController(), animated: true)}let seperator = SparkleSeperatorView(color: R.Color.BackgroundTertiary)diff --git a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/J2MESettingView.swift b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/J2MESettingView.swiftindex 2ffdaae2..2a5de429 100644--- a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/J2MESettingView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/J2MESettingView.swift@@ -327,7 +327,7 @@ class J2MESettingView: BaseView {view.dataSource = selfview.delegate = selfview.isFocusable = true- view.contentInset = .insets(bottom: R.Size.ContentInsetBottom)+ view.contentInset = .insets(bottom: R.Size.ContentInsetBottom(window: hostingWindow))return view}()diff --git a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/LibretroCoverSearchView.swift b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/LibretroCoverSearchView.swiftindex 6be18e3d..dd9656b9 100644--- a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/LibretroCoverSearchView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/LibretroCoverSearchView.swift@@ -41,8 +41,9 @@ class LibretroCoverSearchView: BaseView {detail: R.string.localizable.aiCoverSearchDesc(),confirmTitle: R.string.localizable.goToUpgrade(),confirmAutoHide: false,- confirmAction: {- topViewController()?.present(PurchaseViewController(), animated: true)+ confirmAction: { [weak self] in+ guard let self else { return }+ topViewController(in: self.hostingWindowScene)?.present(PurchaseViewController(), animated: true)})} else {self.searchCover(text: searchText)@@ -60,7 +61,7 @@ class LibretroCoverSearchView: BaseView {view.dataSource = selfview.delegate = selfview.allowsMultipleSelection = true- view.contentInset = .insets(bottom: R.Size.ContentInsetBottom)+ view.contentInset = .insets(bottom: R.Size.ContentInsetBottom(window: hostingWindow))view.blankSlateView = BlankSlateEmptyView(title: R.string.localizable.noGameCoverResult())return view}()@@ -216,11 +217,12 @@ extension LibretroCoverSearchView: UICollectionViewDelegate {collectionView.deselectItem(at: indexPath, animated: true)let game = self.datas[indexPath.row]if let url = URL(string: game.onlineCoverUrl) {+ let scene = hostingWindowSceneKingfisherManager.shared.retrieveImage(with: url) { [weak self] result inguard let self = self else { return }switch result {case .success(let imageResult):- ImageFetcher.edit(image: imageResult.image) { [weak self] image in+ ImageFetcher.edit(image: imageResult.image, in: scene) { [weak self] image inguard let self = self else { return }Task { @MainActor inself.didSelectIamge?(image)diff --git a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/PSXSBIImportView.swift b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/PSXSBIImportView.swiftindex 1035a808..5b523428 100644--- a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/PSXSBIImportView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/PSXSBIImportView.swift@@ -35,7 +35,7 @@ class PSXSBIImportView: BaseView {view.dataSource = selfview.delegate = selfview.isFocusable = true- view.contentInset = .insets(bottom: R.Size.ContentInsetBottom)+ view.contentInset = .insets(bottom: R.Size.ContentInsetBottom(window: hostingWindow))return view}()@@ -114,7 +114,7 @@ extension PSXSBIImportView: UICollectionViewDataSource {guard let self else { return }if let sbi = UTType(filenameExtension: "sbi") {let supportedType = [sbi]- FilesImporter.shared.presentImportController(supportedTypes: supportedType, allowsMultipleSelection: false) { [weak self] urls in+ FilesImporter.shared.presentImportController(supportedTypes: supportedType, allowsMultipleSelection: false, manualHandle: { [weak self] urls inguard let self else { return }if let url = urls.first {do {@@ -126,7 +126,7 @@ extension PSXSBIImportView: UICollectionViewDataSource {UIView.makeToast(message: R.string.localizable.biosImportFailed())}}- }+ }, in: self.hostingWindowScene)}}return celldiff --git a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/SaveStateListView.swift b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/SaveStateListView.swiftindex fd64cec1..936234ef 100644--- a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/SaveStateListView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/SaveStateListView.swift@@ -176,7 +176,7 @@ class SaveStateListView: BaseView {self?.updateContents()})}- })+ }, in: self.hostingWindowScene)}})}@@ -207,7 +207,7 @@ class SaveStateListView: BaseView {cacheUrls.append(cacheUrl)try? FileManager.safeCopyItem(at: $0, to: cacheUrl, shouldReplace: true)})- ShareManager.shareFiles(fileUrls: cacheUrls)+ ShareManager.shareFiles(fileUrls: cacheUrls, in: hostingWindowScene)})} else if let _ = toolValue.tapOthersValue {@@ -258,7 +258,7 @@ class SaveStateListView: BaseView {self.hideCompletion?(state)self.hasCallHideCompletion = true} else {- self.game.handleTapAction(forceQuick: true)+ self.game.handleTapAction(forceQuick: true, in: self.hostingWindowScene)}})} else {@@ -266,7 +266,7 @@ class SaveStateListView: BaseView {self.hideCompletion?(state)self.hasCallHideCompletion = true} else {- self.game.handleTapAction(forceQuick: true, saveState: state)+ self.game.handleTapAction(forceQuick: true, saveState: state, in: self.hostingWindowScene)}}}@@ -372,7 +372,7 @@ class SaveStateListView: BaseView {R.Size.ItemHeightExtraSmall -R.Size.ContentSpaceLarge -R.Size.ContentSpaceLarge -- R.Size.ContentInsetBottom+ R.Size.ContentInsetBottom(window: hostingWindow)return .init(cells: [.custom(ASBlankSlateView(.init(title: R.string.localizable.readyGameSaveStatesEmpty())))],decoration: .init(enable: false),diff --git a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/SteamGridDBContentsView.swift b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/SteamGridDBContentsView.swiftindex 03a967e8..6ac84455 100644--- a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/SteamGridDBContentsView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/SteamGridDBContentsView.swift@@ -122,7 +122,7 @@ class SteamGridDBContentsView: BaseView {private func resolvedContainerWidth() -> CGFloat {if bounds.width > 1 { return bounds.width }- if R.Size.WindowSize.width > 1 { return R.Size.WindowSize.width }+ if R.Size.ApplicationWindowSize.width > 1 { return R.Size.ApplicationWindowSize.width }return 390}@@ -174,6 +174,7 @@ class SteamGridDBContentsView: BaseView {return}UIView.makeLoading()+ let scene = hostingWindowSceneKingfisherManager.shared.retrieveImage(with: url) { [weak self] result inTask { @MainActor inUIView.hideLoading()@@ -181,7 +182,7 @@ class SteamGridDBContentsView: BaseView {guard let self else { return }switch result {case .success(let imageResult):- ImageFetcher.edit(image: imageResult.image) { editedImage in+ ImageFetcher.edit(image: imageResult.image, in: scene) { editedImage inTask { @MainActor inself.didSelectImage?(editedImage)if self.showAsSheet {@@ -247,7 +248,7 @@ class SteamGridDBContentsView: BaseView {sections: contentSections(),blankSlate: .init(detail: R.string.localizable.noGameCoverResult()),backgroundColor: .clear,- listInsets: .insets(bottom: R.Size.ContentInsetBottom),+ listInsets: .insets(bottom: R.Size.ContentInsetBottom(window: hostingWindow)),pageInsets: .insets(top: R.Size.SheetGrabberTopInset))}diff --git a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/SteamGridDBSearchView.swift b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/SteamGridDBSearchView.swiftindex 5be97016..98bb05e4 100644--- a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/SteamGridDBSearchView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/SteamGridDBSearchView.swift@@ -125,8 +125,9 @@ class SteamGridDBSearchView: BaseView {detail: R.string.localizable.aiCoverSearchDesc(),confirmTitle: R.string.localizable.goToUpgrade(),confirmAutoHide: false,- confirmAction: {- topViewController()?.present(PurchaseViewController(), animated: true)+ confirmAction: { [weak self] in+ guard let self else { return }+ topViewController(in: self.hostingWindowScene)?.present(PurchaseViewController(), animated: true)})return}diff --git a/ManicEmu/ManicEmu/Sources/Business/Games/Models/GameOptionPerform.swift b/ManicEmu/ManicEmu/Sources/Business/Games/Models/GameOptionPerform.swiftindex 68eaf676..c278357d 100644--- a/ManicEmu/ManicEmu/Sources/Business/Games/Models/GameOptionPerform.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Games/Models/GameOptionPerform.swift@@ -14,6 +14,7 @@ import Hapticaextension GameOption {func performAction(with games: [Game],+ in scene: UIWindowScene?,performImmediately: Bool = false,accessoryChange: (() -> Void)? = nil,reloadAll: (() -> Void)? = nil) {@@ -56,7 +57,7 @@ extension GameOption {})case .shareRom:- ShareManager.shareFiles(games: games, shareFileType: .rom)+ ShareManager.shareFiles(games: games, shareFileType: .rom, in: scene)case .importSave:if showSaveTipsIfNeed(games: games) {@@ -67,10 +68,10 @@ extension GameOption {let zip = UTType(filenameExtension: "zip") {types += [zip]}- FilesImporter.shared.presentImportController(supportedTypes: types, allowsMultipleSelection: false) { urls in+ FilesImporter.shared.presentImportController(supportedTypes: types, allowsMultipleSelection: false, manualHandle: { urls inif var url = urls.first {if firstGame.gameType == ._3ds || firstGame.gameType == .psp {- FilesImporter.importFiles(urls: [url])+ FilesImporter.importFiles(urls: [url], in: scene)} else {//try to fix j2meJS savesif firstGame.gameType == .j2me,@@ -98,13 +99,13 @@ extension GameOption {}}}- }+ }, in: scene)case .shareSave:if showSaveTipsIfNeed(games: games) {return}- ShareManager.shareFiles(games: games, shareFileType: .save)+ ShareManager.shareFiles(games: games, shareFileType: .save, in: scene)case .delete:UIView.makeAlert(title: R.string.localizable.gamesDelete(),@@ -341,7 +342,7 @@ extension GameOption {} else {resumeEmulationIfNeed()}- })+ }, in: scene)}, hideAction: { type inif type != .confirm {resumeEmulationIfNeed()@@ -414,13 +415,13 @@ extension GameOption {performSwitchAction(with: games, accessoryChange: accessoryChange)case .azaharEmulationAccuracy:- performStringAction(with: games, accessoryChange: accessoryChange)+ performStringAction(with: games, in: scene, accessoryChange: accessoryChange)case .pspJitType:breakcase .pspRenderer:- performStringAction(with: games, accessoryChange: accessoryChange)+ performStringAction(with: games, in: scene, accessoryChange: accessoryChange)case .pspTexture:performSwitchAction(with: games, accessoryChange: accessoryChange)@@ -465,13 +466,13 @@ extension GameOption {case .ps1ControllerMode:- performStringAction(with: games, accessoryChange: accessoryChange)+ performStringAction(with: games, in: scene, accessoryChange: accessoryChange)case .ps1Sbi:PSXSBIImportView.show(game: firstGame)case .ps1Renderer:- performStringAction(with: games, accessoryChange: accessoryChange)+ performStringAction(with: games, in: scene, accessoryChange: accessoryChange)case .n64TransferPak:let options = [@@ -509,7 +510,7 @@ extension GameOption {} else if index == 1 {//from filesif let gb = UTType(filenameExtension: "gb"), let gbc = UTType(filenameExtension: "gbc"), let sav = UTType(filenameExtension: "sav") {- FilesImporter.shared.presentImportController(supportedTypes: [gb, gbc, sav]) { urls in+ FilesImporter.shared.presentImportController(supportedTypes: [gb, gbc, sav], manualHandle: { urls inguard urls.count == 2 else {UIView.makeToast(message: R.string.localizable.transferPakImportError())return@@ -550,7 +551,7 @@ extension GameOption {try? FileManager.safeCopyItem(at: URL(fileURLWithPath: savePath), to: URL(fileURLWithPath: firstGame.romUrl.path + ".sav"), shouldReplace: true)UIView.makeToast(message: R.string.localizable.alertImportFilesSuccess())- }+ }, in: scene)}} else {//turn off@@ -563,10 +564,10 @@ extension GameOption {case .n64RdpPlugin:- performStringAction(with: games, accessoryChange: accessoryChange)+ performStringAction(with: games, in: scene, accessoryChange: accessoryChange)case .ndsSystemType:- performStringAction(with: games, accessoryChange: accessoryChange)+ performStringAction(with: games, in: scene, accessoryChange: accessoryChange)case .ndsGbaSlot:let options = [@@ -604,7 +605,7 @@ extension GameOption {} else if index == 1 {//from filesif let gba = UTType(filenameExtension: "gba"), let sav = UTType(filenameExtension: "sav") {- FilesImporter.shared.presentImportController(supportedTypes: [gba, sav]) { urls in+ FilesImporter.shared.presentImportController(supportedTypes: [gba, sav], manualHandle: { urls inguard urls.count == 1 || urls.count == 2 else {UIView.makeToast(message: R.string.localizable.gbaSlotImportError())return@@ -652,7 +653,7 @@ extension GameOption {try? FileManager.safeCopyItem(at: URL(fileURLWithPath: savePath), to: URL(fileURLWithPath: firstGame.romUrl.path + ".slot.sav"), shouldReplace: true)}UIView.makeToast(message: R.string.localizable.alertImportFilesSuccess())- }+ }, in: scene)}} else {@@ -668,10 +669,10 @@ extension GameOption {performSwitchAction(with: games, accessoryChange: accessoryChange)case .clownMDTvStandard:- performStringAction(with: games, accessoryChange: accessoryChange)+ performStringAction(with: games, in: scene, accessoryChange: accessoryChange)case .snesVRAM:- performStringAction(with: games, accessoryChange: accessoryChange)+ performStringAction(with: games, in: scene, accessoryChange: accessoryChange)case .coreSettings:pauseEmulationIfNeed()@@ -701,7 +702,7 @@ extension GameOption {confirmTitle: R.string.localizable.goToUpgrade(),confirmAutoHide: false,confirmAction: {- topViewController()?.present(PurchaseViewController(), animated: true)+ topViewController(in: scene)?.present(PurchaseViewController(), animated: true)}, hideAction: { _ inresumeEmulationIfNeed()})@@ -727,9 +728,9 @@ extension GameOption {case .fastForward:if performImmediately {- performFastForward(games: games, speed: firstGame.speed.next)+ performFastForward(games: games, speed: firstGame.speed.next, in: scene)} else {- performStringAction(with: games, accessoryChange: accessoryChange)+ performStringAction(with: games, in: scene, accessoryChange: accessoryChange)}case .shaders:@@ -767,7 +768,7 @@ extension GameOption {if performImmediately {performHaptic(games: games, haptic: firstGame.haptic.next)} else {- performStringAction(with: games, accessoryChange: accessoryChange)+ performStringAction(with: games, in: scene, accessoryChange: accessoryChange)}case .airplay:@@ -786,7 +787,7 @@ extension GameOption {if performImmediately {performOrientation(games: games, orientation: firstGame.orientation.next)} else {- performStringAction(with: games, accessoryChange: accessoryChange)+ performStringAction(with: games, in: scene, accessoryChange: accessoryChange)}case .gameOptionSort:@@ -802,7 +803,7 @@ extension GameOption {if performImmediately {performResolution(games: games, resolution: firstGame.resolution.next)} else {- performStringAction(with: games, accessoryChange: accessoryChange)+ performStringAction(with: games, in: scene, accessoryChange: accessoryChange)}case .consoleHome:@@ -865,9 +866,11 @@ extension GameOption {try? FileManager.safeCopyItem(at: url, to: URL(fileURLWithPath: toPath), shouldReplace: true)let palette = Game.NESPalette(name: url.lastPathComponent.deletingPathExtension, type: .custom)firstGame.nesPalettes.append(palette)- GameOption.palette.performAction(with: games, accessoryChange: accessoryChange)+ GameOption.palette.performAction(with: games,+ in: scene,+ accessoryChange: accessoryChange)}- })+ }, in: scene)})}@@ -897,17 +900,17 @@ extension GameOption {})} else {- performStringAction(with: games, accessoryChange: accessoryChange)+ performStringAction(with: games, in: scene, accessoryChange: accessoryChange)}case .swapDisk:- performStringAction(with: games, accessoryChange: accessoryChange)+ performStringAction(with: games, in: scene, accessoryChange: accessoryChange)case .airPlayScaling:- performStringAction(with: games, accessoryChange: accessoryChange)+ performStringAction(with: games, in: scene, accessoryChange: accessoryChange)case .airPlayLayout:- performStringAction(with: games, accessoryChange: accessoryChange)+ performStringAction(with: games, in: scene, accessoryChange: accessoryChange)case .triggerPro:let triggers = Trigger.supportTriggers(gameType: firstGame.gameType)@@ -980,7 +983,7 @@ extension GameOption {}case .screenScaling:- performStringAction(with: games, accessoryChange: accessoryChange)+ performStringAction(with: games, in: scene, accessoryChange: accessoryChange)case .insertDisc:pauseEmulationIfNeed()@@ -1035,7 +1038,7 @@ extension GameOption {resumeEmulationIfNeed()}, cancelHandle: {resumeEmulationIfNeed()- })+ }, in: scene)}}, hideAction: { type inif type == .other {@@ -1079,23 +1082,23 @@ extension GameOption {}case .symbianDevice:- performStringAction(with: games, accessoryChange: accessoryChange)+ performStringAction(with: games, in: scene, accessoryChange: accessoryChange)case .wiiControllerMode:- performStringAction(with: games, accessoryChange: accessoryChange)+ performStringAction(with: games, in: scene, accessoryChange: accessoryChange)case .coverScraping:GameCoverScrapingView.show(games: games)case .dolphinCpuCore:- performStringAction(with: games, accessoryChange: accessoryChange)+ performStringAction(with: games, in: scene, accessoryChange: accessoryChange)case .slowMotion:if performImmediately,let speed = GameOption.SlowMotionSpeed(rawValue: firstGame.getExtraInt(key: ExtraKey.slowMotionSpeed.rawValue) ?? 0) {- performSlowMotion(games: games, speed: speed.next)+ performSlowMotion(games: games, speed: speed.next, in: scene)} else {- performStringAction(with: games, accessoryChange: accessoryChange)+ performStringAction(with: games, in: scene, accessoryChange: accessoryChange)}case .wswanRotation:@@ -1111,7 +1114,7 @@ extension GameOption {], flush: false)}} else {- performStringAction(with: games, accessoryChange: accessoryChange)+ performStringAction(with: games, in: scene, accessoryChange: accessoryChange)}case .ndsLidToggle:@@ -1272,7 +1275,9 @@ extension GameOption {}}- private func performStringAction(with games: [Game], accessoryChange: (() -> Void)? = nil) {+ private func performStringAction(with games: [Game],+ in scene: UIWindowScene?,+ accessoryChange: (() -> Void)? = nil) {guard let firstGame = games.first else { return }var options = [String]()@@ -1443,7 +1448,7 @@ extension GameOption {})} else if self == .fastForward {if let speed = GameOption.FastForwardSpeed(rawValue: index+1) {- performFastForward(games: games, speed: speed)+ performFastForward(games: games, speed: speed, in: scene)}} else if self == .haptic {if let haptic = GameOption.HapticType(rawValue: index) {@@ -1600,7 +1605,7 @@ extension GameOption {})} else if self == .slowMotion {if let speed = GameOption.SlowMotionSpeed(rawValue: index) {- performSlowMotion(games: games, speed: speed)+ performSlowMotion(games: games, speed: speed, in: scene)}} else if self == .wswanRotation {games.forEach({@@ -1620,7 +1625,8 @@ extension GameOption {}private func performFastForward(games: [Game],- speed: GameOption.FastForwardSpeed) {+ speed: GameOption.FastForwardSpeed,+ in scene: UIWindowScene?) {guard let firstGame = games.first else { return }if !PurchaseManager.isMember && speed.rawValue > GameOption.FastForwardSpeed.two.rawValue {pauseEmulationIfNeed()@@ -1637,7 +1643,7 @@ extension GameOption {resumeEmulationIfNeed()UIView.makeToast(message: R.string.localizable.gameSettingFastForwardResume())}, confirmAction: {- topViewController()?.present(PurchaseViewController(), animated: true)+ topViewController(in: scene)?.present(PurchaseViewController(), animated: true)}, hideAction: { type inif type == .other {resumeEmulationIfNeed()@@ -1805,7 +1811,8 @@ extension GameOption {}private func performSlowMotion(games: [Game],- speed: GameOption.SlowMotionSpeed) {+ speed: GameOption.SlowMotionSpeed,+ in scene: UIWindowScene?) {guard games.count > 0 else { return }if !PurchaseManager.isMember && speed.rawValue > GameOption.SlowMotionSpeed.two.rawValue {pauseEmulationIfNeed()@@ -1823,7 +1830,7 @@ extension GameOption {resumeEmulationIfNeed()UIView.makeToast(message: R.string.localizable.gameSettingFastForwardResume())}, confirmAction: {- topViewController()?.present(PurchaseViewController(), animated: true)+ topViewController(in: scene)?.present(PurchaseViewController(), animated: true)}, hideAction: { type inif type == .other {resumeEmulationIfNeed()diff --git a/ManicEmu/ManicEmu/Sources/Business/Games/ViewControllers/GamesViewController.swift b/ManicEmu/ManicEmu/Sources/Business/Games/ViewControllers/GamesViewController.swiftindex ba387808..e1088d82 100644--- a/ManicEmu/ManicEmu/Sources/Business/Games/ViewControllers/GamesViewController.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Games/ViewControllers/GamesViewController.swift@@ -16,18 +16,19 @@ class GamesViewController: BaseViewController {private lazy var gamesNavigationView: GamesNavigationView = {let view = GamesNavigationView()view.controllerButton.didTapButton = { [weak self] in- guard let self = self else { return }+ guard let self else { return }self.showSideMenu(leftSide: true)}view.historyButton.didTapButton = { [weak self] in- guard let self = self else { return }+ guard let self else { return }self.showSideMenu(leftSide: false)}view.scrollToTopView.addTapGesture { [weak self] gesture in- if UIDevice.isPhone && UIDevice.isLandscape {- self?.gamesListView?.scrollToTop()+ guard let self else { return }+ if UIDevice.isPhone && self.view.prefferedLayoutStyle == .landscape {+ self.gamesListView?.scrollToTop()}}@@ -94,7 +95,7 @@ class GamesViewController: BaseViewController {view.needsUpdateToolViewVisible = { [weak self] show inguard let self = self,UIDevice.isPhone,- !UIDevice.isLandscape,+ self.view.prefferedLayoutStyle == .portrait,self.gamesToolView.isHidden != !show else { return }self.gamesListView?.snp.updateConstraints { make in@@ -120,7 +121,7 @@ class GamesViewController: BaseViewController {if empty {self.gamesToolView.stopSearch()}- if UIDevice.isPhone && UIDevice.isLandscape {+ if UIDevice.isPhone && self.view.prefferedLayoutStyle == .landscape {self.gamesToolView.isHidden = true} else {self.gamesToolView.isHidden = empty@@ -154,13 +155,13 @@ class GamesViewController: BaseViewController {override func viewDidLoad() {super.viewDidLoad()- self.updateViews()+ self.updateViews(isLandscape: view.prefferedLayoutStyle == .landscape)//处理Launch Linkif let launchGameID = ApplicationSceneDelegate.launchGameID {ApplicationSceneDelegate.launchGameID = nillet realm = Database.realmif let game = realm.object(ofType: Game.self, forPrimaryKey: launchGameID) {- game.handleTapAction(forceQuick: true)+ game.handleTapAction(forceQuick: true, in: hostingWindowScene)}} else {DispatchQueue.main.asyncAfter(delay: 5, execute: {@@ -188,9 +189,7 @@ class GamesViewController: BaseViewController {super.viewWillTransition(to: size, with: coordinator)//侧栏关闭不阻塞视图交接 否则横屏视图会先被压到竖屏宽度再卸载hideSideMenu()-- let isTargetLandscape = size.width > size.height- if isTargetLandscape {+ if size.IsRelativelyWideRectangle {//竖→横:等父容器已经是横屏尺寸后再挂上横屏视图 避免导航栏在430宽度下约束冲突coordinator.animate(alongsideTransition: { [weak self] _ inself?.updateViews(isLandscape: true)@@ -206,7 +205,7 @@ class GamesViewController: BaseViewController {}override func handleScreenPanGesture(edges: UIRectEdge, gesture: UIScreenEdgePanGestureRecognizer) {- if UIDevice.isPhone || (UIDevice.isPad && !UIDevice.isLandscape) {+ if UIDevice.isPhone || (UIDevice.isPad && view.prefferedLayoutStyle == .portrait) {if edges == .left {showSideMenu(leftSide: true)} else if edges == .right {@@ -241,7 +240,7 @@ class GamesViewController: BaseViewController {guard let self = self else { return }if Settings.defalut.quickGame {self.hideSideMenu(completion: {- game.handleTapAction(forceQuick: true)+ game.handleTapAction(forceQuick: true, in: self.hostingWindowScene)})} else {// Wait for side menu dismiss before presenting GameInfo; overlapping@@ -263,10 +262,10 @@ class GamesViewController: BaseViewController {menu.presentDuration = R.Numbers.LongAnimationDurationmenu.dismissDuration = R.Numbers.LongAnimationDurationmenu.leftSide = leftSide- menu.menuWidth = R.Size.SideMenuWidth+ menu.menuWidth = R.Size.SideMenuWidth(window: hostingWindow)menu.presentationStyle = SideMenuShowStyle()sideMenu = menu- topViewController()?.present(menu, animated: true)+ topViewController(in: hostingWindowScene)?.present(menu, animated: true)}private func hideSideMenu(completion: (()->Void)? = nil) {@@ -278,7 +277,7 @@ class GamesViewController: BaseViewController {}///按目标方向交接横竖屏列表 先挂上新视图再卸掉旧视图 避免露出底层背景- private func updateViews(isLandscape: Bool = UIDevice.isLandscape) {+ private func updateViews(isLandscape: Bool) {if isLandscape {if gameListLandscapeView?.superview != nil { return }@@ -305,7 +304,7 @@ class GamesViewController: BaseViewController {view.addSubview(gamesNavigationView)}gamesNavigationView.snp.remakeConstraints { make in- make.top.equalToSuperview().offset(R.Size.ContentInsetTop)+ make.top.equalToSuperview().offset(R.Size.ContentInsetTop(window: hostingWindow))make.leading.trailing.equalTo(view.safeAreaLayoutGuide)make.height.equalTo(R.Size.ItemHeightMedium)}@@ -368,12 +367,12 @@ class GamesViewController: BaseViewController {}func updateLandscapeBackgroundIfNeed() {- guard UIDevice.isLandscape else { return }+ guard view.prefferedLayoutStyle == .landscape else { return }gameListLandscapeView?.updateFocusedGameInfo()}func scrollToLastGame() {- if UIDevice.isLandscape {+ if view.prefferedLayoutStyle == .landscape {gameListLandscapeView?.scrollToLastGame()} else {gamesListView?.scrollToLastGame()@@ -381,7 +380,7 @@ class GamesViewController: BaseViewController {}func scrollToFirstGame() {- if UIDevice.isLandscape {+ if view.prefferedLayoutStyle == .landscape {gameListLandscapeView?.scrollToFirstGame()} else {gamesListView?.scrollToFirstGame()diff --git a/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameCollectionViewCell.swift b/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameCollectionViewCell.swiftindex 67d3b3b3..d5e1d3dc 100644--- a/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameCollectionViewCell.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameCollectionViewCell.swift@@ -104,7 +104,12 @@ class GameCollectionViewCell: UICollectionViewCell {fatalError("init(coder:) has not been implemented")}- func setData(game: Game, isSelect: Bool = false, highlightString: String? = nil, coverSize: CGSize, showTitle: Bool = true, indexPath: IndexPath) {+ func setData(game: Game,+ isSelect: Bool = false,+ highlightString: String? = nil,+ coverSize: CGSize,+ showTitle: Bool = true,+ indexPath: IndexPath) {self.indexPath = indexPathgameType = game.gameTypetitleLabel.isHidden = !showTitlediff --git a/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameCoverView.swift b/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameCoverView.swiftindex 05a023ff..1bf1e0b9 100644--- a/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameCoverView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameCoverView.swift@@ -102,6 +102,7 @@ class GameCoverView: BaseView {updateStyle(style,gameType: game.gameType,scalePlatform: scalePlatform,+ coverSize: coverSize,gameTypeCategory: gameTypeCategory)if !R.Style.GameHideRating {@@ -134,7 +135,8 @@ class GameCoverView: BaseView {imageView.contentMode = .centerupdateStyle(style,gameType: gameType,- scalePlatform: scalePlatform)+ scalePlatform: scalePlatform,+ coverSize: CGSize(150))if R.Style.GameHideRating {ratingView.isHidden = true} else {@@ -150,9 +152,14 @@ class GameCoverView: BaseView {func updateStyle(_ style: CoverStyle,gameType: GameType,scalePlatform: Bool = true,+ coverSize: CGSize,gameTypeCategory: Int = 0) {self.style = style- platformView.image = Self.getPlatformImage(gameType: gameType, style: style, scalePlatform: scalePlatform, gameTypeCategory: gameTypeCategory)+ platformView.image = Self.getPlatformImage(gameType: gameType,+ style: style,+ scalePlatform: scalePlatform,+ coverSize: coverSize,+ gameTypeCategory: gameTypeCategory)switch style {case .style1:imageView.snp.remakeConstraints { make in@@ -204,9 +211,14 @@ class GameCoverView: BaseView {}private static var platformImageCaches = [String: UIImage?]()- static func getPlatformImage(gameType: GameType, style: CoverStyle, scalePlatform: Bool = true, gameTypeCategory: Int = 0) -> UIImage? {+ static func getPlatformImage(gameType: GameType,+ style: CoverStyle,+ scalePlatform: Bool = true,+ coverSize: CGSize,+ gameTypeCategory: Int = 0) -> UIImage? {guard style != .style1 else { return nil }- let key = gameType.rawValue + "_\(style.rawValue)" + (UIDevice.isPhone && !UIDevice.isLandscape && scalePlatform ? "_\(R.Style.GamesPerRow)" : "") + "_\(gameTypeCategory)"+ guard coverSize != .zero else { return nil }+ let key = gameType.rawValue + "_\(style.rawValue)" + (scalePlatform ? "_\(coverSize)" : "") + "_\(gameTypeCategory)"if let image = GameCoverView.platformImageCaches[key] {return image} else {@@ -338,8 +350,11 @@ class GameCoverView: BaseView {} else if gameType == .ps2 {image = style == .style2 ? R.image.ps2_cover_v() : R.image.ps2_cover_h()}- if UIDevice.isPhone, !UIDevice.isLandscape, scalePlatform, R.Style.GamesPerRow != 2, let unwrapImage = image {- image = unwrapImage.scaled(toWidth: unwrapImage.size.width * (1/(R.Style.GamesPerRow-1)))+ if scalePlatform,+ coverSize != .zero,+ coverSize.width <= 150,+ let unwrapImage = image {+ image = unwrapImage.scaled(toWidth: unwrapImage.size.width * coverSize.width/150)}GameCoverView.platformImageCaches[key] = imagereturn imagediff --git a/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameLandscapeCarouselCell.swift b/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameLandscapeCarouselCell.swiftindex ff2c409b..7c87611e 100644--- a/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameLandscapeCarouselCell.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameLandscapeCarouselCell.swift@@ -255,7 +255,7 @@ class GameLandscapeCarouselCell: UICollectionViewCell {emptyCardView.isHidden = falseemptyContentStack.isHidden = falsecardView.snp.updateConstraints { make in- make.centerY.equalToSuperview().offset(-((R.Size.NavigationHeight + R.Size.ContentInsetTop)/2))+ make.centerY.equalToSuperview().offset(-((R.Size.NavigationHeight + R.Size.ContentInsetTop(window: hostingWindow))/2))make.size.equalTo(cardSize.height)}emptyCardView.snp.updateConstraints { make indiff --git a/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameListLandscapeView.swift b/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameListLandscapeView.swiftindex 60b10dbf..76c36d33 100644--- a/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameListLandscapeView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameListLandscapeView.swift@@ -37,7 +37,7 @@ class GameListLandscapeView: BaseView {guard let view = PlayHistoryView.show() else { return }view.didTapGame = { [weak self] game inguard let self else { return }- game.handleTapAction()+ game.handleTapAction(in: self.hostingWindowScene)}}return view@@ -126,7 +126,7 @@ class GameListLandscapeView: BaseView {view.delegate = selfview.alwaysBounceVertical = trueview.isFocusable = true- let bottom = UIDevice.isPhone ? R.Size.ContentSpaceLarge : R.Size.ContentInsetBottom + R.Size.HomeTabBarSize.height + R.Size.ContentSpaceLarge+ let bottom = UIDevice.isPhone ? R.Size.ContentSpaceLarge : R.Size.ContentInsetBottom(window: hostingWindow) + R.Size.HomeTabBarSize.height + R.Size.ContentSpaceLargeview.contentInset = .insets(bottom: bottom)view.isHidden = LandscapeCarouselStyle.isCarouselEnabledview.addLongPressGesture(handler: { [weak self] gesture in@@ -165,7 +165,7 @@ class GameListLandscapeView: BaseView {let view = ASButtonView(button)view.didTapButton = { [weak self] inguard let self, let game = self.focusedGame else { return }- game.handleTapAction(forceQuick: true)+ game.handleTapAction(forceQuick: true, in: self.hostingWindowScene)}return view}()@@ -312,7 +312,7 @@ class GameListLandscapeView: BaseView {navigationView.snp.makeConstraints { make inmake.leading.trailing.equalToSuperview()make.height.equalTo(R.Size.NavigationHeight)- make.top.equalToSuperview().offset(R.Size.ContentInsetTop)+ make.top.equalToSuperview().offset(R.Size.ContentInsetTop(window: hostingWindow))}navigationView.addSubview(filterButton)@@ -967,7 +967,7 @@ class GameListLandscapeView: BaseView {self.showDynamicBackgroundSheet()}, cancelHandle: { [weak self] inself?.showDynamicBackgroundSheet()- })+ }, in: self.hostingWindowScene)})}return .dismiss()@@ -1038,7 +1038,7 @@ class GameListLandscapeView: BaseView {self.showBackgroundMusicSheet()}, cancelHandle: { [weak self] inself?.showBackgroundMusicSheet()- })+ }, in: self.hostingWindowScene)})}return .dismiss()@@ -1663,7 +1663,7 @@ extension GameListLandscapeView: UICollectionViewDataSource {let carouselHeight = carouselView.bounds.height > 0 ? carouselView.bounds.height : 300return max(carouselHeight - GameLandscapeCarouselCell.infoPanelReserve - R.Size.ContentSpaceLarge, 100)} else {- return R.Size.WindowHeight/3+ return R.Size.ApplicationWindowSize.height/3}}@@ -1708,8 +1708,9 @@ extension GameListLandscapeView: UICollectionViewDataSource {showTitle: !R.Style.GamesHideTitle,indexPath: indexPath)cell.isFocusable = true- cell.onFocusConfirm = {- game.handleTapAction()+ cell.onFocusConfirm = { [weak self] in+ guard let self else { return true }+ game.handleTapAction(in: self.hostingWindowScene)return true}}@@ -1752,7 +1753,7 @@ extension GameListLandscapeView: UICollectionViewDelegate {func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool {if isListCollectionView(collectionView) {if let game = listGame(at: indexPath) {- game.handleTapAction()+ game.handleTapAction(in: hostingWindowScene)}return false}@@ -1771,7 +1772,7 @@ extension GameListLandscapeView: UICollectionViewDelegate {focusCarouselPage(indexPath.row, animated: true)} else if let game = focusedGame {UIDevice.generateHaptic()- game.handleTapAction()+ game.handleTapAction(in: hostingWindowScene)}}diff --git a/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameListView.swift b/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameListView.swiftindex 10f83c30..8bfe4852 100644--- a/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameListView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameListView.swift@@ -22,7 +22,7 @@ class GameListView: BaseView {view.dataSource = selfview.delegate = selfview.allowsMultipleSelection = true- let bottom = R.Size.ContentInsetBottom + R.Size.HomeTabBarSize.height + R.Size.ContentSpaceLarge+ let bottom = R.Size.ContentInsetBottom(window: hostingWindow) + R.Size.HomeTabBarSize.height + R.Size.ContentSpaceLargeview.contentInset = .insets(bottom: bottom)view.blankSlateView = GamesListBlankSlateView()view.addLongPressGesture(handler: { [weak self] gesture in@@ -67,12 +67,12 @@ class GameListView: BaseView {if index == 0 {//deleteif let selectedIndexPaths = self.collectionView.indexPathsForSelectedItems {- GameOption.delete.performAction(with: selectedIndexPaths.compactMap({ self.getGame(at: $0) }))+ GameOption.delete.performAction(with: selectedIndexPaths.compactMap({ self.getGame(at: $0) }), in: self.hostingWindowScene)}} else if index == 1 {//skinif let selectedIndexPaths = self.collectionView.indexPathsForSelectedItems {- GameOption.skins.performAction(with: selectedIndexPaths.compactMap({ self.getGame(at: $0) }))+ GameOption.skins.performAction(with: selectedIndexPaths.compactMap({ self.getGame(at: $0) }), in: self.hostingWindowScene)}}}@@ -159,10 +159,6 @@ class GameListView: BaseView {private var lastToolViewScrollTimestamp: TimeInterval = 0private var isToolViewScrollInitialized = falseprivate var lastSelectSection = 0- private let gamesNavigationBottom = (R.Size.SafeArea.top > 0 ? R.Size.SafeArea.top : R.Size.ContentSpaceLarge) + R.Size.ItemHeightMedium- private var gamesToolBottom: CGFloat {- gamesNavigationBottom + R.Size.GamesToolViewHeight- }private var notificationTokens = [Any]()@@ -578,7 +574,7 @@ class GameListView: BaseView {private func createLayout() -> UICollectionViewLayout {let layout = UICollectionViewCompositionalLayout { [weak self] sectionIndex, env in- guard let self = self else { return nil }+ guard let self else { return nil }let gameType = self.sortDatasKeys()[sectionIndex]let itemSpacing = R.Size.ContentSpaceMedium - R.Size.GamesListSelectionEdge*2let sectionInsetTop = R.Size.ContentSpaceTiny@@ -589,7 +585,11 @@ class GameListView: BaseView {let group: NSCollectionLayoutGroupvar column = R.Style.GamesPerRowif UIDevice.isPad {- column = (UIDevice.isPadMini ? 4 : 5 )+ if let w = self.hostingWindow {+ column = min(max((w.width/120).rounded(numberOfDecimalPlaces: -1, rule: .toNearestOrEven), 2), 5)+ } else {+ column = (UIDevice.isPadMini ? 4 : 5 )+ }}let widthDimension: NSCollectionLayoutDimension = .fractionalWidth(1/column)//item布局@@ -1011,7 +1011,7 @@ extension GameListView: UICollectionViewDataSource {let randomSection = Int(arc4random()) % self.normalDatas.countif let games = self.normalDatas[self.sortDatasKeys()[randomSection]] {let randomGame = games[Int(arc4random()) % games.count]- randomGame.handleTapAction(forceQuick: true)+ randomGame.handleTapAction(forceQuick: true, in: self.hostingWindowScene)}}return header@@ -1069,7 +1069,7 @@ extension GameListView: UICollectionViewDelegate {}if let game = getGame(at: indexPath) {- game.handleTapAction()+ game.handleTapAction(in: hostingWindowScene)}return false}@@ -1150,7 +1150,7 @@ private extension GameListView {func updateToolViewVisibility(for scrollView: UIScrollView) {guard UIDevice.isPhone,- scrollView.contentSize.height >= R.Size.WindowHeight else { return }+ scrollView.contentSize.height >= (hostingWindow?.height ?? R.Size.ApplicationWindowSize.height) else { return }let contentOffsetY = clampedContentOffsetY(for: scrollView)let now = CACurrentMediaTime()diff --git a/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameOptionsView.swift b/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameOptionsView.swiftindex 823feee1..8f093527 100644--- a/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameOptionsView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameOptionsView.swift@@ -250,7 +250,9 @@ class GameOptionsView: BaseView {let option = optionGroups[groupIndex.section][groupIndex.row]let shouldHide = shouldHideBlock?(option) ?? false- option.performAction(with: games, accessoryChange: { [weak self] in+ option.performAction(with: games,+ in: hostingWindowScene,+ accessoryChange: { [weak self] inguard let self, !shouldHide else { return }self.listPageView.updateCellData(self.getCell(option: option), indexPath: indexPath)}, reloadAll: { [weak self] in@@ -271,7 +273,7 @@ class GameOptionsView: BaseView {}} else if let index = navigationValue.tapToolsValue {if shortcuts.count > index {- shortcuts[index].performAction(with: games)+ shortcuts[index].performAction(with: games, in: hostingWindowScene)}}}@@ -314,7 +316,7 @@ extension GameOptionsView: ShowableView {var prefferdConstraintHeight: CGFloat? {if scene == .gaming,UIDevice.isPhone,- UIDevice.isPortrait,+ proHUDLayoutStyle() == .portrait,PlayViewController.menuInsets == nil {return Self.MaxHeightForGaming ?? R.Size.SheetWindowMaxSize.height} else if scene == .common {@@ -324,7 +326,7 @@ extension GameOptionsView: ShowableView {height += options.reduce(0.0, { result, _ in result + R.Size.ItemHeightLarge })})height += R.Size.ContentSpaceLarge- height += R.Size.ContentInsetBottom+ height += R.Size.ContentInsetBottom(window: hostingWindow)return height}return R.Size.SheetWindowMaxSize.heightdiff --git a/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameplayManualsView.swift b/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameplayManualsView.swiftindex e900dce2..bd9538cd 100644--- a/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameplayManualsView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameplayManualsView.swift@@ -60,7 +60,7 @@ class GameplayManualsView: BaseView {self.pdfView.autoScales = true} catch {}}- })+ }, in: self.hostingWindowScene)}}return viewdiff --git a/ManicEmu/ManicEmu/Sources/Business/Games/Views/GamesCollectionReusableView.swift b/ManicEmu/ManicEmu/Sources/Business/Games/Views/GamesCollectionReusableView.swiftindex 08e2b747..4d9749d1 100644--- a/ManicEmu/ManicEmu/Sources/Business/Games/Views/GamesCollectionReusableView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Games/Views/GamesCollectionReusableView.swift@@ -123,7 +123,7 @@ class GamesCollectionReusableView: UICollectionReusableView {gamesCountButton.setTitleString("\(gamesCount) \(R.string.localizable.tabbarTitleGames())")gamesCountButton.isUserInteractionEnabled = allowsFold- if !allowsFold || (UIDevice.isPhone && UIDevice.isLandscape) {+ if !allowsFold || (UIDevice.isPhone && self.prefferedLayoutStyle == .landscape) {gamesCountButton.setIcon(nil)} else {gamesCountButton.setIcon(.symbol(isFolded ? .chevronDown : .chevronUp, colors: [R.Color.LabelSecondary]))diff --git a/ManicEmu/ManicEmu/Sources/Business/Games/Views/GamesListBlankSlateView.swift b/ManicEmu/ManicEmu/Sources/Business/Games/Views/GamesListBlankSlateView.swiftindex 37b51ab2..01c24fe9 100644--- a/ManicEmu/ManicEmu/Sources/Business/Games/Views/GamesListBlankSlateView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Games/Views/GamesListBlankSlateView.swift@@ -143,7 +143,7 @@ class GamesListBlankSlateView: BaseView {warnningContainer.layerCornerRadius = R.Size.ButtonExtraSmall/2containerView.addSubview(warnningContainer)warnningContainer.snp.makeConstraints { make in- make.bottom.equalToSuperview().offset(-(R.Size.ContentInsetBottom + R.Size.ItemHeightLarge + ((Device.size().rawValue < Size.screen5_8Inch.rawValue || UIDevice.isPad) ? R.Size.ContentSpaceHuge : R.Size.ContentSpaceSmall)))+ make.bottom.equalToSuperview().offset(-(R.Size.ContentInsetBottom(window: hostingWindow) + R.Size.ItemHeightLarge + ((Device.size().rawValue < Size.screen5_8Inch.rawValue || UIDevice.isPad) ? R.Size.ContentSpaceHuge : R.Size.ContentSpaceSmall)))make.centerX.equalToSuperview()make.leading.greaterThanOrEqualToSuperview().offset(R.Size.ContentSpaceLarge)make.trailing.lessThanOrEqualToSuperview().offset(-R.Size.ContentSpaceLarge)diff --git a/ManicEmu/ManicEmu/Sources/Business/History/Views/PlayHistoryView.swift b/ManicEmu/ManicEmu/Sources/Business/History/Views/PlayHistoryView.swiftindex 58712d28..d778c21d 100644--- a/ManicEmu/ManicEmu/Sources/Business/History/Views/PlayHistoryView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/History/Views/PlayHistoryView.swift@@ -39,11 +39,11 @@ class PlayHistoryView: BaseView {view.dataSource = selfview.delegate = selfview.contentInset = .insets(top: R.Size.ContentSpaceSmall,- bottom: R.Size.ContentInsetBottom)+ bottom: R.Size.ContentInsetBottom(window: hostingWindow))view.blankSlateView = PlayHistoryBlankSlateView(tapAction: { [weak self] type inguard let self = self else { return }if type == .importGame {- FilesImporter.shared.presentImportController(supportedTypes: UTType.gameTypes)+ FilesImporter.shared.presentImportController(supportedTypes: UTType.gameTypes, in: self.hostingWindowScene)} else if type == .startGame {if self.showAsSheet {self.hide()@@ -64,7 +64,7 @@ class PlayHistoryView: BaseView {required init?(parameters: Any...) {self.asSideMenu = parameters.compactMap({ $0 as? Bool }).first ?? false- super.init(frame: CGRect(origin: .zero, size: R.Size.WindowSize))+ super.init(frame: CGRect(origin: .zero, size: R.Size.ApplicationWindowSize))addSubview(navigationView)navigationView.snp.makeConstraints { make indiff --git a/ManicEmu/ManicEmu/Sources/Business/Home/ViewControllers/HomeViewController.swift b/ManicEmu/ManicEmu/Sources/Business/Home/ViewControllers/HomeViewController.swiftindex d8f8e473..40f38c2e 100644--- a/ManicEmu/ManicEmu/Sources/Business/Home/ViewControllers/HomeViewController.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Home/ViewControllers/HomeViewController.swift@@ -41,7 +41,7 @@ class HomeViewController: BaseViewController {manager.contentView.insertSubview(backgroundMask, at: 0)backgroundMask.snp.makeConstraints { make inmake.leading.top.trailing.equalToSuperview()- make.height.equalTo(R.Size.PageBackgroundMaskHeight)+ make.height.equalTo(R.Size.PageBackgroundMaskHeight(window: hostingWindow))}}childControllers.forEach {@@ -54,6 +54,7 @@ class HomeViewController: BaseViewController {lazy var homeTabBar: HomeTabBar = {let view = HomeTabBar()view.selectionChange = { [weak self] selection in+ guard let self else { return }var selection = selectionif Locale.isRTLLanguage {if selection == .games {@@ -62,37 +63,37 @@ class HomeViewController: BaseViewController {selection = .games}}- self?.pageViewManager.setCurrentPage(selection.rawValue)+ self.pageViewManager.setCurrentPage(selection.rawValue)switch selection {case .games:Log.debug("切换到游戏")- if UIDevice.isPhone, UIDevice.isLandscape {- self?.gamesViewController.view.masksToBounds = false+ if UIDevice.isPhone, self.view.prefferedLayoutStyle == .landscape {+ self.gamesViewController.view.masksToBounds = false}case .imports:Log.debug("切换到导入")- if UIDevice.isPhone, UIDevice.isLandscape {- self?.gamesViewController.view.masksToBounds = true+ if UIDevice.isPhone, self.view.prefferedLayoutStyle == .landscape {+ self.gamesViewController.view.masksToBounds = true}case .settings:Log.debug("切换到设置")}- self?.updateLandscapeBackgroundVisible()- self?.activateCurrentTabFocusContext()+ self.updateLandscapeBackgroundVisible()+ self.activateCurrentTabFocusContext()}- view.isHidden = UIDevice.isPhone && UIDevice.isLandscape+ view.isHidden = UIDevice.isPhone && self.view.prefferedLayoutStyle == .landscapereturn view}()- private var homeTabBarBlurView: UIView = {+ private lazy var homeTabBarBlurView: UIView = {let view = BlurUIKit.VariableBlurView()view.direction = .upview.maximumBlurRadius = 1view.dimmingAlpha = .interfaceStyle(lightModeAlpha: 0.05, darkModeAlpha: 0.05)view.dimmingTintColor = R.Color.BackgroundPrimary- view.isHidden = UIDevice.isLandscape+ view.isHidden = self.view.prefferedLayoutStyle == .landscapereturn view}()@@ -162,8 +163,8 @@ class HomeViewController: BaseViewController {override func viewWillAppear(_ animated: Bool) {super.viewWillAppear(animated)landscapeBackgroundView.setHomeVisible(true)- if let coordinator = transitionCoordinator {- let size = R.Size.WindowSize+ if let coordinator = transitionCoordinator,+ let size = view.hostingWindow?.size {viewWillTransition(to: size, with: coordinator)childControllers.forEach { $0.viewWillTransition(to: size, with: coordinator) }}@@ -197,7 +198,7 @@ class HomeViewController: BaseViewController {if !UIDevice.isIOS15 {NotificationCenter.default.post(name: R.NotificationName.ViewWillTransition, object: nil)}- homeTabBarBlurView.isHidden = UIDevice.isLandscape+ homeTabBarBlurView.isHidden = view.prefferedLayoutStyle == .landscapeif currentChildViewController is GamesViewController {updateGamesFocusCommands(focusContext: currentChildViewController.focusContext)}@@ -206,7 +207,7 @@ class HomeViewController: BaseViewController {if UIDevice.isPhone {if let pageBackgroundMaskView = self.pageViewManager.contentView.subviews.first(where: { $0.isKind(of: PageBackgroundMaskView.self) }) {pageBackgroundMaskView.snp.updateConstraints { make in- make.height.equalTo(R.Size.PageBackgroundMaskHeight)+ make.height.equalTo(R.Size.PageBackgroundMaskHeight(window: self.hostingWindow))}}}@@ -215,7 +216,7 @@ class HomeViewController: BaseViewController {NotificationCenter.default.post(name: R.NotificationName.ViewWillTransition, object: nil)}NotificationCenter.default.post(name: R.NotificationName.ViewAlongsideTransition, object: nil)- self.homeTabBar.isHidden = UIDevice.isPhone && UIDevice.isLandscape+ self.homeTabBar.isHidden = UIDevice.isPhone && self.view.prefferedLayoutStyle == .landscape}, completion: { _ inNotificationCenter.default.post(name: R.NotificationName.ViewDidTransition, object: nil)})@@ -257,8 +258,8 @@ class HomeViewController: BaseViewController {homeTabBar.snp.makeConstraints { make inmake.size.equalTo(R.Size.HomeTabBarSize)make.centerX.equalTo(self.view)- if R.Size.SafeArea.top == 0 {- make.bottom.equalToSuperview().inset(R.Size.ContentInsetBottom)+ if self.view.safeAreaInsets.bottom == 0 {+ make.bottom.equalToSuperview().inset(R.Size.ContentInsetBottom(window: hostingWindow))} else {make.bottom.equalTo(view.safeAreaLayoutGuide)}@@ -267,7 +268,7 @@ class HomeViewController: BaseViewController {///根据横竖屏更新动态背景显隐 横屏时透明化分页容器与子页面使背景透出private func updateLandscapeBackgroundVisible() {- let landscape = UIDevice.isLandscape+ let landscape = view.prefferedLayoutStyle == .landscapeif landscape {if UIDevice.isPhone {if landscapeBackgroundView.isHidden {@@ -386,7 +387,7 @@ class HomeViewController: BaseViewController {private func updateGamesFocusCommands(focusContext: FocusContext) {guard currentChildViewController is GamesViewController else { return }- if UIDevice.isLandscape {+ if view.prefferedLayoutStyle == .landscape {focusContext.addCommand(FocusCommand(key: FocusKey("l3"), title: R.string.localizable.filterTitle(), action: {NotificationCenter.default.post(name: R.NotificationName.ShowFilterForLandscapeMode, object: nil)}))diff --git a/ManicEmu/ManicEmu/Sources/Business/Import/ViewControllers/ImportViewController.swift b/ManicEmu/ManicEmu/Sources/Business/Import/ViewControllers/ImportViewController.swiftindex d99f928a..9b08490d 100644--- a/ManicEmu/ManicEmu/Sources/Business/Import/ViewControllers/ImportViewController.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Import/ViewControllers/ImportViewController.swift@@ -41,11 +41,19 @@ class ImportViewController: BaseViewController {self.setupViews()}+ override func viewDidLayoutSubviews() {+ super.viewDidLayoutSubviews()+ if UIDevice.isPad, hostingWindow != nil {+ updateViewsForIpad()+ }+ }+override func viewWillTransition(to size: CGSize, with coordinator: any UIViewControllerTransitionCoordinator) {super.viewWillTransition(to: size, with: coordinator)- if UIDevice.isPhone {- coordinator.animate(alongsideTransition: nil) { [weak self] _ in- self?.hideSideMenu()+ coordinator.animate(alongsideTransition: nil) { [weak self] _ in+ guard let self else { return }+ if UIDevice.isPhone || (UIDevice.isPad && self.view.isWindowHasEnoughSpaceforIpadMultiColumnLayout) {+ self.hideSideMenu()}}}@@ -61,26 +69,48 @@ class ImportViewController: BaseViewController {view.backgroundColor = UIColor(.dm, light: .white, dark: .black)importServiceListView.backgroundColor = R.Color.BackgroundPrimaryview.addSubview(importServiceListView)- importServiceListView.snp.makeConstraints { make in+ }+ }++ private func updateViewsForIpad() {+ guard UIDevice.isPad else { return }+ guard let hostingWindow else { return }+ if view.isWindowHasEnoughSpaceforIpadMultiColumnLayout {+ let sideMenuWidth = R.Size.SideMenuWidth(window: hostingWindow)*1.2+ importServiceListView.snp.remakeConstraints { make inmake.top.bottom.trailing.equalToSuperview()- make.width.equalToSuperview().offset(-R.Size.SideMenuWidth*1.2)+ if sideMenuWidth <= hostingWindow.width/2 {+ make.width.equalToSuperview().offset(-sideMenuWidth)+ } else {+ make.width.equalToSuperview().offset(-hostingWindow.width/2)+ }}+ addImportServiceView.removeFromSuperview()view.addSubview(addImportServiceView)- addImportServiceView.snp.makeConstraints { make in++ addImportServiceView.snp.remakeConstraints { make inmake.leading.top.bottom.equalToSuperview()make.trailing.equalTo(importServiceListView.snp.leading)}+ cornerMaskViewForiPad.removeFromSuperview()view.addSubview(cornerMaskViewForiPad)- cornerMaskViewForiPad.snp.makeConstraints { make in+ cornerMaskViewForiPad.snp.remakeConstraints { make inmake.edges.equalTo(importServiceListView)}+ } else {+ importServiceListView.snp.remakeConstraints { make in+ make.top.bottom.equalToSuperview()+ make.leading.trailing.equalTo(view.safeAreaLayoutGuide)+ }+ addImportServiceView.removeFromSuperview()+ cornerMaskViewForiPad.removeFromSuperview()}}override func handleScreenPanGesture(edges: UIRectEdge, gesture: UIScreenEdgePanGestureRecognizer) {- if UIDevice.isPhone || (UIDevice.isPad && !UIDevice.isLandscape) {+ if UIDevice.isPhone || (UIDevice.isPad && view.prefferedLayoutStyle == .portrait) {if edges == .left {showSideMenu()}@@ -101,9 +131,9 @@ class ImportViewController: BaseViewController {menu.presentDuration = R.Numbers.LongAnimationDurationmenu.dismissDuration = R.Numbers.LongAnimationDurationmenu.leftSide = !Locale.isRTLLanguage- menu.menuWidth = R.Size.SideMenuWidth+ menu.menuWidth = R.Size.SideMenuWidth(window: hostingWindow)menu.presentationStyle = SideMenuShowStyle()- topViewController()?.present(menu, animated: true)+ topViewController(in: hostingWindowScene)?.present(menu, animated: true)sideMenu = menu}diff --git a/ManicEmu/ManicEmu/Sources/Business/Import/Views/AddImportServiceView.swift b/ManicEmu/ManicEmu/Sources/Business/Import/Views/AddImportServiceView.swiftindex 2cacd105..5bebfc8e 100644--- a/ManicEmu/ManicEmu/Sources/Business/Import/Views/AddImportServiceView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Import/Views/AddImportServiceView.swift@@ -29,7 +29,7 @@ class AddImportServiceView: BaseView {let view = ASListPageView(.init(navigation: navigation,sections: sections,backgroundColor: .clear,- pageInsets: .insets(top: R.Size.ContentInsetTop),+ pageInsets: .insets(top: R.Size.ContentInsetTop(window: hostingWindow)),enableSafeAreaLeftInsets: true,enableSafeAreaRightInsets: true))@@ -37,13 +37,13 @@ class AddImportServiceView: BaseView {guard let self else { return }if let indexPath = action.normalItemValue?.indexPath {if !PurchaseManager.isMember {- topViewController()?.present(PurchaseViewController(featuresType: .import), animated: true)+ topViewController(in: self.hostingWindowScene)?.present(PurchaseViewController(featuresType: .import), animated: true)return}let service: ImportServiceif indexPath.section == 0 {service = cloudServices[indexPath.row]- CloudDriveConnetor.shard.connect(service: service)+ CloudDriveConnetor.shard.connect(service: service, in: self.hostingWindowScene)} else if indexPath.section == 1 {service = LanServices[indexPath.row]LanServiceEditView.show(serviceType: service.type, successHandler: { [weak self] indiff --git a/ManicEmu/ManicEmu/Sources/Business/Import/Views/AddUrlGameView.swift b/ManicEmu/ManicEmu/Sources/Business/Import/Views/AddUrlGameView.swiftindex 638c8c8c..8992c092 100644--- a/ManicEmu/ManicEmu/Sources/Business/Import/Views/AddUrlGameView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Import/Views/AddUrlGameView.swift@@ -292,7 +292,7 @@ class AddUrlGameView: BaseView {sources.append(.delete)}- ImageFetcher.showCommonFetcher(sources: sources) { [weak self] image, source in+ ImageFetcher.showCommonFetcher(sources: sources, in: hostingWindowScene) { [weak self] image, source inguard let self else { return }if case .delete = source {self.coverRemoved = truediff --git a/ManicEmu/ManicEmu/Sources/Business/Import/Views/ImportMottoCollectionViewCell.swift b/ManicEmu/ManicEmu/Sources/Business/Import/Views/ImportMottoCollectionViewCell.swiftindex 484ac6a6..fd7f4554 100644--- a/ManicEmu/ManicEmu/Sources/Business/Import/Views/ImportMottoCollectionViewCell.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Import/Views/ImportMottoCollectionViewCell.swift@@ -8,10 +8,6 @@class ImportMottoCollectionViewCell: UICollectionViewCell {- private var cellHeight: CGFloat {- UIDevice.isLandscape ? 100 : 220- }-private let imageView = ASIconView(.image(R.image.import_ip()!))private let labelView = {var text = ASText.mediumText(R.string.localizable.importTopHintTitle(),@@ -19,14 +15,6 @@ class ImportMottoCollectionViewCell: UICollectionViewCell {numberOfLines: 0)text.attributes?.alignment = .centerreturn ASLabelView(text: text)--// let label = UILabel()-// label.text = R.string.localizable.importTopHintTitle()-// label.font = R.Font.Body2()-// label.textColor = R.Color.LabelSecondary-// label.numberOfLines = 0-// label.textAlignment = .center-// return label}()private let backgroundGradientView = GradientView()@@ -43,7 +31,7 @@ class ImportMottoCollectionViewCell: UICollectionViewCell {keepCellHeightView.snp.makeConstraints { make inmake.edges.equalToSuperview()- make.height.equalTo(cellHeight).priority(.high)+ make.height.equalTo(220).priority(.high)}let bg = R.Color.BackgroundPrimary@@ -61,7 +49,7 @@ class ImportMottoCollectionViewCell: UICollectionViewCell {make.leading.trailing.bottom.equalToSuperview()make.height.equalTo(R.Size.ItemHeightSmall)}- updateViews()+ updateViews(isLandscape: false)}required init?(coder: NSCoder) {@@ -76,7 +64,7 @@ class ImportMottoCollectionViewCell: UICollectionViewCell {height: backgroundGradientView.height*2))).cgPathbackgroundGradientView.layer.mask = ovalLayer- if UIDevice.isPhone, UIDevice.isLandscape {+ if UIDevice.isPhone, prefferedLayoutStyle == .landscape {keepCellHeightView.backgroundColor = R.Color.BackgroundSecondarybackgroundGradientView.isHidden = true} else {@@ -85,8 +73,8 @@ class ImportMottoCollectionViewCell: UICollectionViewCell {}}- func updateViews() {- if UIDevice.isLandscape {+ func updateViews(isLandscape: Bool) {+ if isLandscape {imageView.snp.remakeConstraints { make inmake.trailing.equalToSuperview().offset(R.Size.ContentSpaceSmall)make.bottom.equalToSuperview().offset(R.Size.ContentSpaceHuge)@@ -99,7 +87,7 @@ class ImportMottoCollectionViewCell: UICollectionViewCell {}keepCellHeightView.snp.updateConstraints { make in- make.height.equalTo(cellHeight).priority(.high)+ make.height.equalTo(100).priority(.high)}} else {imageView.snp.remakeConstraints { make in@@ -115,7 +103,7 @@ class ImportMottoCollectionViewCell: UICollectionViewCell {}keepCellHeightView.snp.updateConstraints { make in- make.height.equalTo(cellHeight).priority(.high)+ make.height.equalTo(220).priority(.high)}}}diff --git a/ManicEmu/ManicEmu/Sources/Business/Import/Views/ImportNavigationView.swift b/ManicEmu/ManicEmu/Sources/Business/Import/Views/ImportNavigationView.swiftindex fe248ed6..5b9cb489 100644--- a/ManicEmu/ManicEmu/Sources/Business/Import/Views/ImportNavigationView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Import/Views/ImportNavigationView.swift@@ -82,3 +82,11 @@ class ImportNavigationView: BaseView {]}}++extension ImportNavigationView: ViewTransition {+ func viewAlongsideTransition() {+ if UIDevice.isPad {+ addServiceButton.isHidden = isWindowHasEnoughSpaceforIpadMultiColumnLayout+ }+ }+}diff --git a/ManicEmu/ManicEmu/Sources/Business/Import/Views/ImportServiceListView.swift b/ManicEmu/ManicEmu/Sources/Business/Import/Views/ImportServiceListView.swiftindex 75d04599..99060f63 100644--- a/ManicEmu/ManicEmu/Sources/Business/Import/Views/ImportServiceListView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Import/Views/ImportServiceListView.swift@@ -123,7 +123,16 @@ class ImportServiceListView: BaseView {importNavigationView.snp.makeConstraints { make inmake.leading.trailing.equalToSuperview()make.height.equalTo(R.Size.NavigationHeight)- make.top.equalToSuperview().offset(UIDevice.isPhone && UIDevice.isLandscape ? 0 : R.Size.ContentInsetTop)+ make.top.equalToSuperview().offset(UIDevice.isPhone ? 0 : R.Size.ContentInsetTop(window: hostingWindow))+ }+ }++ override func layoutSubviews() {+ super.layoutSubviews()+ if UIDevice.isPhone {+ importNavigationView.snp.updateConstraints { make in+ make.top.equalToSuperview().offset(UIDevice.isPhone && isLandscapeLayout ? 0 : R.Size.ContentInsetTop(window: hostingWindow))+ }}}@@ -131,14 +140,23 @@ class ImportServiceListView: BaseView {fatalError("init(coder:) has not been implemented")}+ private var isLandscapeLayout: Bool {+ var isLandscape = prefferedLayoutStyle == .landscape+ if isLandscape, UIDevice.isPad, isWindowHasEnoughSpaceforIpadMultiColumnLayout {+ isLandscape = false+ }+ return isLandscape+ }+private func createLayout() -> UICollectionViewLayout {- let layout = UICollectionViewCompositionalLayout { sectionIndex, env in-+ let layout = UICollectionViewCompositionalLayout { [weak self] sectionIndex, env in+ guard let self else { return nil }+ let isLandscape = self.isLandscapeLayoutlet widthDimension: NSCollectionLayoutDimensionif sectionIndex == 0 {- widthDimension = .fractionalWidth(UIDevice.isLandscape ? 0.5 : 1)+ widthDimension = .fractionalWidth(isLandscape ? 0.5 : 1)} else {- widthDimension = .fractionalWidth(UIDevice.isLandscape ? 0.25 : 0.5)+ widthDimension = .fractionalWidth(isLandscape ? 0.25 : 0.5)}let heightDimension: NSCollectionLayoutDimension@@ -156,9 +174,9 @@ class ImportServiceListView: BaseView {//grouplet count: Intif sectionIndex == 0 {- count = UIDevice.isLandscape ? 2 : 1+ count = isLandscape ? 2 : 1} else {- count = UIDevice.isLandscape ? 4 : 2+ count = isLandscape ? 4 : 2}let groupLayoutSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1),heightDimension: heightDimension)@@ -196,11 +214,11 @@ class ImportServiceListView: BaseView {}private func getCollectionViewContentInset() -> UIEdgeInsets {- var top = R.Size.ContentInsetTop- if UIDevice.isLandscape {+ var top = R.Size.ContentInsetTop(window: hostingWindow)+ if isLandscapeLayout {top += (R.Size.NavigationHeight + R.Size.ContentSpaceLarge)}- let bottom = R.Size.ContentInsetBottom + R.Size.HomeTabBarSize.height + R.Size.ContentSpaceLarge+ let bottom = R.Size.ContentInsetBottom(window: hostingWindow) + R.Size.HomeTabBarSize.height + R.Size.ContentSpaceLargereturn .insets(top: top, bottom: bottom)}}@@ -208,16 +226,16 @@ class ImportServiceListView: BaseView {extension ImportServiceListView: ViewTransition {func viewWillTransition() {if let cell = collectionView.cellForItem(at: IndexPath(row: 0, section: 0)) as? ImportMottoCollectionViewCell {- cell.updateViews()+ cell.updateViews(isLandscape: isLandscapeLayout)}}func viewAlongsideTransition() {if UIDevice.isPhone {importNavigationView.snp.updateConstraints { make in- make.top.equalToSuperview().offset(UIDevice.isPhone && UIDevice.isLandscape ? 0 : R.Size.ContentInsetTop)+ make.top.equalToSuperview().offset(UIDevice.isPhone && isLandscapeLayout ? 0 : R.Size.ContentInsetTop(window: hostingWindow))}- } else if UIDevice.isPad, UIDevice.isLandscape {+ } else if UIDevice.isPad, isLandscapeLayout {collectionView.contentInset = getCollectionViewContentInset()}}@@ -253,7 +271,7 @@ extension ImportServiceListView: UICollectionViewDataSource {let enableSelectedEffect = WebServer.shard.isRunning ? true : falseif isOn {cell?.enablePressEffect = enableSelectedEffect- WebServer.shard.start()+ WebServer.shard.start(in: self?.hostingWindowScene)service?.detail = R.string.localizable.importServiceListWiFiOnDetail(WebServer.shard.ipAddress)} else {cell?.enablePressEffect = enableSelectedEffect@@ -309,7 +327,7 @@ extension ImportServiceListView: UICollectionViewDelegate {}if indexPath.section == 0, indexPath.row == 1 {//files- FilesImporter.shared.presentImportController()+ FilesImporter.shared.presentImportController(in: hostingWindowScene)return}@@ -324,12 +342,12 @@ extension ImportServiceListView: UICollectionViewDelegate {case .paste://读取粘贴板- PasteImporter.paste()+ PasteImporter.paste(in: hostingWindowScene)case .googledrive, .dropbox, .onedrive, .baiduyun, .aliyun:if !PurchaseManager.isMember {- topViewController()?.present(PurchaseViewController(featuresType: .import), animated: true)+ topViewController(in: hostingWindowScene)?.present(PurchaseViewController(featuresType: .import), animated: true)return}@@ -345,7 +363,7 @@ extension ImportServiceListView: UICollectionViewDelegate {case .samba, .webdav, .romm:if !PurchaseManager.isMember {- topViewController()?.present(PurchaseViewController(featuresType: .import), animated: true)+ topViewController(in: hostingWindowScene)?.present(PurchaseViewController(featuresType: .import), animated: true)return}diff --git a/ManicEmu/ManicEmu/Sources/Business/Import/Views/MultiDiscBuilderView.swift b/ManicEmu/ManicEmu/Sources/Business/Import/Views/MultiDiscBuilderView.swiftindex 9d3fad54..6274cc17 100644--- a/ManicEmu/ManicEmu/Sources/Business/Import/Views/MultiDiscBuilderView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Import/Views/MultiDiscBuilderView.swift@@ -118,7 +118,7 @@ class MultiDiscBuilderView: BaseView {guard let self else { return }if let index {if let url = self.generateM3uFile() {- ShareManager.shareFile(fileUrl: url)+ ShareManager.shareFile(fileUrl: url, in: self.hostingWindowScene)} else {UIView.makeToast(message: R.string.localizable.generateM3uFailed())}@@ -143,7 +143,7 @@ class MultiDiscBuilderView: BaseView {view.dragInteractionEnabled = trueview.dragDelegate = selfview.dropDelegate = self- let bottom = (UIDevice.isPad ? (R.Size.ContentInsetBottom + R.Size.HomeTabBarSize.height + R.Size.ContentSpaceLarge) : R.Size.ContentInsetBottom) + R.Size.ItemHeightMedium + R.Size.ContentSpaceMedium+ let bottom = (UIDevice.isPad ? (R.Size.ContentInsetBottom(window: hostingWindow) + R.Size.HomeTabBarSize.height + R.Size.ContentSpaceLarge) : R.Size.ContentInsetBottom(window: hostingWindow)) + R.Size.ItemHeightMedium + R.Size.ContentSpaceMediumview.contentInset = .insets(top: R.Size.ContentSpaceSmall,bottom: bottom)return view@@ -186,7 +186,7 @@ class MultiDiscBuilderView: BaseView {addToLibraryButton.snp.makeConstraints { make inmake.leading.trailing.equalToSuperview().inset(R.Size.ContentSpaceHuge)make.height.equalTo(R.Size.ItemHeightMedium)- make.bottom.equalToSuperview().offset(-R.Size.ContentInsetBottom-R.Size.ContentSpaceMedium)+ make.bottom.equalToSuperview().offset(-R.Size.ContentInsetBottom(window: hostingWindow)-R.Size.ContentSpaceMedium)}}@@ -227,7 +227,7 @@ class MultiDiscBuilderView: BaseView {urls.append(subItem)}}- FilesImporter.importFiles(urls: urls)+ FilesImporter.importFiles(urls: urls, in: hostingWindowScene)hasAddToLibrary = true} else {UIView.makeToast(message: R.string.localizable.generateM3uFailed())@@ -340,7 +340,7 @@ extension MultiDiscBuilderView: UICollectionViewDelegate {if indexPath.section == datas.count + 1 {let supportedTypes = contentTypes(for: playlistFormat.pickerExtensions)guard !supportedTypes.isEmpty else { return }- FilesImporter.shared.presentImportController(supportedTypes: supportedTypes) { [weak self] urls in+ FilesImporter.shared.presentImportController(supportedTypes: supportedTypes, manualHandle: { [weak self] urls inguard let self else { return }let urls = urls.sorted(by: { $0.path < $1.path })let selectedExts = Set(urls.map { $0.pathExtension.lowercased() }.filter { !$0.isEmpty })@@ -403,7 +403,7 @@ extension MultiDiscBuilderView: UICollectionViewDelegate {} else {UIView.makeToast(message: R.string.localizable.multiDiscImportErrorMissing())}- }+ }, in: hostingWindowScene)}}}diff --git a/ManicEmu/ManicEmu/Sources/Business/OnlinePlay/Views/ArticBaseCollectionCell.swift b/ManicEmu/ManicEmu/Sources/Business/OnlinePlay/Views/ArticBaseCollectionCell.swiftindex 514e3f6e..e42d9f26 100644--- a/ManicEmu/ManicEmu/Sources/Business/OnlinePlay/Views/ArticBaseCollectionCell.swift+++ b/ManicEmu/ManicEmu/Sources/Business/OnlinePlay/Views/ArticBaseCollectionCell.swift@@ -161,7 +161,7 @@ class ArticBaseCollectionCell: UICollectionViewCell {game.importDate = Date()game.defaultCore = 1try? realm.write { realm.add(game) }- game.handleTapAction(forceQuick: true)+ game.handleTapAction(forceQuick: true, in: self.hostingWindowScene)}})})diff --git a/ManicEmu/ManicEmu/Sources/Business/OnlinePlay/Views/OnlinePlaySettingView.swift b/ManicEmu/ManicEmu/Sources/Business/OnlinePlay/Views/OnlinePlaySettingView.swiftindex 6a48c159..256ed4d3 100644--- a/ManicEmu/ManicEmu/Sources/Business/OnlinePlay/Views/OnlinePlaySettingView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/OnlinePlay/Views/OnlinePlaySettingView.swift@@ -45,7 +45,7 @@ class OnlinePlaySettingView: BaseView {let view = ASListPageView(.init(navigation: navigation,sections: sections,backgroundColor: .clear,- pageInsets: .insets(top: showClose ? R.Size.SheetGrabberTopInset : R.Size.ContentInsetTop)))+ pageInsets: .insets(top: showClose ? R.Size.SheetGrabberTopInset : R.Size.ContentInsetTop(window: hostingWindow))))view.didActionOccurred = { [weak self] action inguard let self else { return }if let navigationValue = action.navigationValue {diff --git a/ManicEmu/ManicEmu/Sources/Business/OnlinePlay/Views/PSPNetworkingView.swift b/ManicEmu/ManicEmu/Sources/Business/OnlinePlay/Views/PSPNetworkingView.swiftindex 31935f7f..a7497abe 100644--- a/ManicEmu/ManicEmu/Sources/Business/OnlinePlay/Views/PSPNetworkingView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/OnlinePlay/Views/PSPNetworkingView.swift@@ -37,7 +37,7 @@ class PSPNetworkingView: BaseView {view.dataSource = selfview.delegate = selfview.isFocusable = true- view.contentInset = .insets(bottom: R.Size.ContentInsetBottom)+ view.contentInset = .insets(bottom: R.Size.ContentInsetBottom(window: hostingWindow))return view}()diff --git a/ManicEmu/ManicEmu/Sources/Business/OnlinePlay/Views/PretendoNetworkingView.swift b/ManicEmu/ManicEmu/Sources/Business/OnlinePlay/Views/PretendoNetworkingView.swiftindex 800c3930..fc12a0c9 100644--- a/ManicEmu/ManicEmu/Sources/Business/OnlinePlay/Views/PretendoNetworkingView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/OnlinePlay/Views/PretendoNetworkingView.swift@@ -36,7 +36,7 @@ class PretendoNetworkingView: BaseView {view.dataSource = selfview.delegate = selfview.isFocusable = true- view.contentInset = .insets(bottom: R.Size.ContentInsetBottom)+ view.contentInset = .insets(bottom: R.Size.ContentInsetBottom(window: hostingWindow))return view}()@@ -223,7 +223,7 @@ extension PretendoNetworkingView: UICollectionViewDataSource {}).filter({$0.isArticBaseHomeMenu}).first {- game.handleTapAction(forceQuick: true)+ game.handleTapAction(forceQuick: true, in: self.hostingWindowScene)return true} else {return falsediff --git a/ManicEmu/ManicEmu/Sources/Business/Play/Models/Game.swift b/ManicEmu/ManicEmu/Sources/Business/Play/Models/Game.swiftindex bea33e64..6530ffe8 100644--- a/ManicEmu/ManicEmu/Sources/Business/Play/Models/Game.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Play/Models/Game.swift@@ -1660,7 +1660,9 @@ class Game: Object, ObjectUpdatable {return .S60v3}- func handleTapAction(forceQuick: Bool = false, saveState: GameSaveState? = nil) {+ func handleTapAction(forceQuick: Bool = false,+ saveState: GameSaveState? = nil,+ in scene: UIWindowScene?) {if isNDSHomeMenuGame {let biosCompletion = gameType.isNDSBiosComplete()if (id == Game.DsHomeMenuPrimaryKey && !biosCompletion.isDSComplete) ||@@ -1668,7 +1670,7 @@ class Game: Object, ObjectUpdatable {// Prompt BIOS import when Home Menu BIOS files are missing.BIOSSelectionView.show(gameType: gameType)} else {- PlayViewController.startGame(game: self, saveState: saveState)+ PlayViewController.startGame(game: self, saveState: saveState, in: scene)}} else if isSymbianHomeMenu {SymbianFirmwareView.show()@@ -1676,7 +1678,7 @@ class Game: Object, ObjectUpdatable {if isUrlGame {EmulatorInteractionKit.openExternalGameURL(urlGameLaunchURL)} else {- PlayViewController.startGame(game: self, saveState: saveState)+ PlayViewController.startGame(game: self, saveState: saveState, in: scene)}} else {if gameType == .unknown {diff --git a/ManicEmu/ManicEmu/Sources/Business/Play/VIewControllers/PlayViewController.swift b/ManicEmu/ManicEmu/Sources/Business/Play/VIewControllers/PlayViewController.swiftindex 7f5aa4f1..374b5a13 100644--- a/ManicEmu/ManicEmu/Sources/Business/Play/VIewControllers/PlayViewController.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Play/VIewControllers/PlayViewController.swift@@ -155,9 +155,9 @@ class PlayViewController: GameViewController {//皮肤中的Switch绑定数据private var skinSwitchBindDatas = [String: Bool]()- static func startGame(game: Game, saveState: GameSaveState? = nil) {+ static func startGame(game: Game, saveState: GameSaveState? = nil, in scene: UIWindowScene?) {if game.isUrlGame {- game.handleTapAction(forceQuick: true)+ game.handleTapAction(forceQuick: true, in: scene)return}if game.gameType == .ns {@@ -204,17 +204,17 @@ class PlayViewController: GameViewController {LibretroCore.sharedInstance().workspace = R.Path.Libretro}if pretendoNetworkingViewHasShownInstance {- topViewController()?.present(PlayViewController(game: game, saveState: saveState), animated: true)- } else if let homeVC = ApplicationSceneDelegate.applicationWindow?.rootViewController as? HomeViewController {+ topViewController(in: scene)?.present(PlayViewController(game: game, saveState: saveState), animated: true)+ } else if let homeVC = UIWindow.applicationWindow?.rootViewController as? HomeViewController {if let vc = homeVC.presentedViewController {vc.dismiss(animated: true) {- topViewController(appController: true)?.present(PlayViewController(game: game, saveState: saveState), animated: true)+ topApplicationViewController()?.present(PlayViewController(game: game, saveState: saveState), animated: true)}} else {- topViewController(appController: true)?.present(PlayViewController(game: game, saveState: saveState), animated: true)+ topApplicationViewController()?.present(PlayViewController(game: game, saveState: saveState), animated: true)}} else {- topViewController(appController: true)?.present(PlayViewController(game: game, saveState: saveState), animated: true)+ topApplicationViewController()?.present(PlayViewController(game: game, saveState: saveState), animated: true)}}if game.gameType == ._3ds, !UIDevice.current.hasA11ProcessorOrBetter, !UserDefaults.standard.bool(forKey: R.DefaultKey.HasShow3DSNotSupportAlert) {@@ -293,7 +293,7 @@ class PlayViewController: GameViewController {FilesSyncManager.shared.ensureROM(for: game) { error inUIView.hideLoading()if error == nil, game.isRomExtsts {- startGame(game: game, saveState: saveState)+ startGame(game: game, saveState: saveState, in: scene)} else if FilesSyncManager.shared.romAvailability(for: game) == .syncing {if availability != .syncing {UIView.makeToast(message: R.string.localizable.iCloudROMStillSyncing())@@ -519,7 +519,7 @@ class PlayViewController: GameViewController {UIView.hideAllAlert()}- GameOption.quit.performAction(with: [self.manicGame])+ GameOption.quit.performAction(with: [self.manicGame], in: self.hostingWindowScene)})notificationTokens.append(center.addObserver(forName: R.NotificationName.MotionShake, object: nil, queue: .main) { [weak self] notification in//设备晃动通知@@ -702,7 +702,7 @@ class PlayViewController: GameViewController {//重置游戏通知guard let self else { return }UIView.hideAllAlert()- GameOption.reload.performAction(with: [self.manicGame])+ GameOption.reload.performAction(with: [self.manicGame], in: self.hostingWindowScene)}))notificationTokens.append(center.addObserver(forName: R.NotificationName.SkinChange, object: nil, queue: .main, using: { [weak self] notification in//皮肤变更@@ -723,7 +723,7 @@ class PlayViewController: GameViewController {DispatchQueue.main.asyncAfter(delay: 3) { [weak self] inguard let self else { return }UIView.hideAllAlert()- GameOption.quit.performAction(with: [self.manicGame])+ GameOption.quit.performAction(with: [self.manicGame], in: self.hostingWindowScene)}})notificationTokens.append(center.addObserver(forName: Notification.Name(rawValue: "AmigaBiosMissingNotification"), object: nil, queue: .main) { notification in@@ -932,7 +932,7 @@ class PlayViewController: GameViewController {override var supportedInterfaceOrientations: UIInterfaceOrientationMask {if #available(iOS 26.0, *) {- return OrientationLockPin.resolvedMask(for: view.window)+ return OrientationLockPin.resolvedMask(for: hostingWindow)}return super.supportedInterfaceOrientations}@@ -954,7 +954,7 @@ class PlayViewController: GameViewController {override func viewWillTransition(to size: CGSize, with coordinator: any UIViewControllerTransitionCoordinator) {OrientationLockPin.resistPortraitTransitionIfNeeded(to: size)- let fromSize = R.Size.WindowSize+ let fromSize = R.Size.ApplicationWindowSizelet toSize = sizeif manicGame.orientation == .portrait {// Portrait lock: ignore landscape-bound transitions.@@ -1135,7 +1135,8 @@ extension PlayViewController {}} else if manicGame.isLibretroType {- LibretroCore.sharedInstance().snapshot { snapshot in+ LibretroCore.sharedInstance().snapshot { [weak self] snapshot in+ guard let self else { return }var image = snapshotif (self.manicGame.gameType == .ds || self.manicGame.isAzahar3DS), let i = image {image = self.snapShotForDualScreen(topOnly: true, source: i)?.first@@ -1240,9 +1241,9 @@ extension PlayViewController {}} else {pauseEmulationIfNeed()- if UIDevice.isPhone && UIDevice.isPortrait {+ if UIDevice.isPhone && view.prefferedLayoutStyle == .portrait {var prefferedMenuHeight = view.height - gameView.frame.maxY- if prefferedMenuHeight < R.Size.WindowHeight/3 {+ if prefferedMenuHeight < R.Size.ApplicationWindowSize.height/3 {prefferedMenuHeight = R.Size.SheetWindowMaxSize.height/2}GameOptionsView.MaxHeightForGaming = max(prefferedMenuHeight, R.Size.SheetWindowMinSize.height)@@ -1292,7 +1293,7 @@ extension PlayViewController {self.resumeEmulationAndHandleAudio()}- topViewController()?.present(vc, animated: true)+ topViewController(in: hostingWindowScene)?.present(vc, animated: true)}}@@ -1308,9 +1309,12 @@ extension PlayViewController {guard MappingOption.availableOptions(games: [manicGame]).contains(where: { $0 == mappingKey }) else { return }if let gameOption = mappingKey.gameOption {- gameOption.performAction(with: [manicGame], performImmediately: true)+ gameOption.performAction(with: [manicGame],+ in: hostingWindowScene,+ performImmediately: true)} else if mappingKey == .j2meSettings || mappingKey == .dosSettings {- GameOption.coreSettings.performAction(with: [manicGame])+ GameOption.coreSettings.performAction(with: [manicGame],+ in: hostingWindowScene)} else if mappingKey == .fastForward2x ||mappingKey == .fastForward3x ||mappingKey == .fastForward4x ||@@ -2454,7 +2458,7 @@ extension PlayViewController {}if let result = Prefference.defalut.getPrefference(kind: .skin,- storeKey: .orientationKey(gameId: manicGame.id, isLandScape: UIDevice.isLandscape),+ storeKey: .orientationKey(gameId: manicGame.id, isLandScape: view.prefferedLayoutStyle == .landscape),bestEfforts: true),let skinId = result.skinValue?.skinId,let skin = Database.realm.object(ofType: Skin.self, forPrimaryKey: skinId),@@ -2678,8 +2682,8 @@ extension PlayViewController {if manicGame.gameType == .ds || manicGame.gameType == ._3ds {dimensions.height = dimensions.height/2}- if manicGame.isCitra3DS {- dimensions = dimensions.applying(CGAffineTransform(scaleX: UIScreen.main.scale, y: UIScreen.main.scale))+ if manicGame.isCitra3DS, let hostingWindow {+ dimensions = dimensions.applying(CGAffineTransform(scaleX: hostingWindow.screen.scale, y: hostingWindow.screen.scale))}aiplayScaledDimensions = airPlayViewController.addLibretroView(gameMetalView, dimensions: dimensions, scalingType: Settings.defalut.airPlayScaling)updateDualScreenViews()@@ -2701,6 +2705,9 @@ extension PlayViewController {if (manicGame.gameType == ._3ds && UIDevice.isPad) || manicGame.isAzaharArticBase {return}+ if let hostingWindow, UIDevice.isWindowAppIPad(window: hostingWindow) {+ return+ }if let controllerSkin = controllerView.controllerSkin {if let skin = Database.realm.objects(Skin.self).first(where: { $0.identifier == controllerSkin.identifier }) {if skin.supportShortcut {@@ -2719,7 +2726,7 @@ extension PlayViewController {if (manicGame.gameType == .ds && UIDevice.isPad) ||manicGame.gameType == .wii ||manicGame.gameType == .ngc ||- (manicGame.gameType == .pce && !UIDevice.isLandscape) ||+ (manicGame.gameType == .pce && view.prefferedLayoutStyle == .portrait) ||manicGame.gameType.usesDOSSkinLayout ||manicGame.gameType == .wsc {iconColor = .black.withAlphaComponent(0.25)@@ -2730,7 +2737,9 @@ extension PlayViewController {button.didTapButton = { [weak self] inguard let self, shortcut != .rewind else { return }shortcut.showSecondPromptIfNeed(continued: {- shortcut.performAction(with: [self.manicGame], performImmediately: true)+ shortcut.performAction(with: [self.manicGame],+ in: self.hostingWindowScene,+ performImmediately: true)})}button.didLongPressButton = { [weak self] state in@@ -2817,7 +2826,7 @@ extension PlayViewController {shortcutsButtonContainer.snp.remakeConstraints { make inif gameViews.count > 1 {//iPhone ds布局比较特殊- if UIDevice.isLandscape {+ if view.prefferedLayoutStyle == .landscape {make.leading.equalTo(gameViews[0]).inset(-33)make.trailing.equalTo(gameViews[1]).inset(-33)make.top.equalToSuperview()@@ -2835,7 +2844,7 @@ extension PlayViewController {make.height.equalTo(96)}} else {- if let displayType = controllerView.controllerSkinTraits?.displayType, displayType == .standard, !UIDevice.isLandscape {+ if let displayType = controllerView.controllerSkinTraits?.displayType, displayType == .standard, view.prefferedLayoutStyle == .portrait {make.height.equalTo(87)} else {make.height.equalTo(113)@@ -2845,15 +2854,15 @@ extension PlayViewController {}} else if manicGame.gameType.usesDOSSkinLayout, UIDevice.isPad {shortcutsButtonContainer.snp.updateConstraints { make in- make.top.equalTo(gameView.snp.bottom).offset(UIDevice.isLandscape ? 30 : 40)+ make.top.equalTo(gameView.snp.bottom).offset(view.prefferedLayoutStyle == .landscape ? 30 : 40)}} else if manicGame.gameType == .ds, UIDevice.isPad {shortcutsButtonContainer.snp.updateConstraints { make in- make.top.equalTo(gameView.snp.bottom).offset(UIDevice.isLandscape ? 25 : 40)+ make.top.equalTo(gameView.snp.bottom).offset(view.prefferedLayoutStyle == .landscape ? 25 : 40)}- } else if manicGame.gameType == .pm && !UIDevice.isLandscape {+ } else if manicGame.gameType == .pm && view.prefferedLayoutStyle == .portrait {shortcutsButtonContainer.snp.updateConstraints { make in- make.leading.trailing.equalTo(gameView).inset(UIDevice.isLandscape ? 0 : 50)+ make.leading.trailing.equalTo(gameView).inset(50)}}}@@ -2861,7 +2870,7 @@ extension PlayViewController {private func updateCitra3DSViews() {guard manicGame.isCitra3DS else { return }guard let controllerSkin = controllerView.controllerSkin as? ControllerSkin else { return }- guard let frames = controllerSkin.getFrames() else { return }+ guard let hostingWindow, let frames = controllerSkin.getFrames(window: hostingWindow) else { return }guard let touchGameViewFrame = frames.touchGameViewFrame else { return }Log.debug("更新3DS视图 frames:\(frames)")@@ -3167,7 +3176,7 @@ extension PlayViewController {j2meView.onExit = { [weak self] inguard let self = self else { return }- GameOption.quit.performAction(with: [self.manicGame])+ GameOption.quit.performAction(with: [self.manicGame], in: self.hostingWindowScene)}var loadSuccess = false@@ -3264,13 +3273,14 @@ extension PlayViewController {let isOriginalShader = usingShaderPath == nil || usingShaderPath == ""if ExternalSceneDelegate.isAirPlaying {+ guard let hostingWindow else { return }let layoutType = Settings.defalut.airPlayLayoutvar layout: String = ""let ratio = 0.3- let scale = isOriginalShader ? UIScreen.main.scale : 1.25+ let scale = isOriginalShader ? hostingWindow.screen.scale : 1.25let dimensions = aiplayScaledDimensions.applying(CGAffineTransform(scaleX: scale, y: scale))- let bufferSize = "\(dimensions.width),\(dimensions.height)"+ let bufferSize = "\(dimensions.width.rounded1()),\(dimensions.height.rounded1())"let bottomRatio = 0.75 //NDS和3DS的bottom屏幕都是3:4switch layoutType {case .embeddedTopLeft, .embeddedTopRight, .embeddedBottomLeft, .embeddedBottomRight:@@ -3319,9 +3329,9 @@ extension PlayViewController {} else if layoutType == .largeSmallBottomRight {bottomOrigin = CGPoint(x: dimensions.width*(1-ratio), y: topY + topHeight - bottomHeight)}- layout = "\(topX),\(topY),\(topWidth),\(topHeight),\(bottomOrigin.x),\(bottomOrigin.y),\(bottomWidth),\(bottomHeight),\(bufferSize)"+ layout = "\(topX.rounded1()),\(topY.rounded1()),\(topWidth.rounded1()),\(topHeight.rounded1()),\(bottomOrigin.x.rounded1()),\(bottomOrigin.y.rounded1()),\(bottomWidth.rounded1()),\(bottomHeight.rounded1()),\(bufferSize)"case .singleScreen:- layout = "\(0),\(0),\(dimensions.width),\(dimensions.height),\(0),\(0),\(0),\(0),\(bufferSize)"+ layout = "\(0),\(0),\(dimensions.width.rounded1()),\(dimensions.height.rounded1()),\(0),\(0),\(0),\(0),\(bufferSize)"}@@ -3361,7 +3371,7 @@ extension PlayViewController {} else {//屏幕需要跟随gameViews的更新而更新guard let controllerSkin = controllerView.controllerSkin as? ControllerSkin else { return }- guard let frames = controllerSkin.getFrames() else { return }+ guard let hostingWindow, let frames = controllerSkin.getFrames(window: hostingWindow) else { return }guard let libretroViewFrame = getDualScreenViewFrame() else { return }if manicGame.isCitra3DS {@@ -3376,7 +3386,7 @@ extension PlayViewController {var layout = ""let absX = abs(skinframe.minX - libretroViewFrame.minX)let absY = abs(skinframe.minY - libretroViewFrame.minY)- let scale = isOriginalShader ? UIScreen.main.scale : 1.25+ let scale = isOriginalShader ? hostingWindow.screen.scale : 1.25let scaleTransform = CGAffineTransform(scaleX: scale, y: scale)var touchGameViewFrame = CGRect.zeroif var bottomFrame = frames.touchGameViewFrame {@@ -3389,20 +3399,20 @@ extension PlayViewController {let scaleTopFrame = topFrame.applying(scaleTransform)let scaleBottomFrame = bottomFrame.applying(scaleTransform)- if !isOriginalShader, manicGame.gameType == ._3ds, UIDevice.isLandscape {+ if !isOriginalShader, manicGame.gameType == ._3ds, view.prefferedLayoutStyle == .landscape {//fix 3DS Scale- let fixScale = UIScreen.main.scale-scale- layout = "\(scaleTopFrame.minX),\(scaleTopFrame.minY),\(scaleTopFrame.width),\(scaleTopFrame.height*fixScale),\(scaleBottomFrame.minX),\(scaleBottomFrame.minY),\(scaleBottomFrame.width),\(scaleBottomFrame.height*fixScale),\(bufferframe.width),\(bufferframe.height*fixScale)"+ let fixScale = hostingWindow.screen.scale-scale+ layout = "\(scaleTopFrame.minX.rounded1()),\(scaleTopFrame.minY.rounded1()),\(scaleTopFrame.width.rounded1()),\((scaleTopFrame.height*fixScale).rounded1()),\((scaleBottomFrame.minX).rounded1()),\(scaleBottomFrame.minY.rounded1()),\(scaleBottomFrame.width.rounded1()),\((scaleBottomFrame.height*fixScale).rounded1()),\(bufferframe.width.rounded1()),\((bufferframe.height*fixScale).rounded1())"} else {- layout = "\(scaleTopFrame.minX),\(scaleTopFrame.minY),\(scaleTopFrame.width),\(scaleTopFrame.height),\(scaleBottomFrame.minX),\(scaleBottomFrame.minY),\(scaleBottomFrame.width),\(scaleBottomFrame.height),\(bufferframe.width),\(bufferframe.height)"+ layout = "\(scaleTopFrame.minX.rounded1()),\(scaleTopFrame.minY.rounded1()),\(scaleTopFrame.width.rounded1()),\(scaleTopFrame.height.rounded1()),\(scaleBottomFrame.minX.rounded1()),\(scaleBottomFrame.minY.rounded1()),\(scaleBottomFrame.width.rounded1()),\(scaleBottomFrame.height.rounded1()),\(bufferframe.width.rounded1()),\(bufferframe.height.rounded1())"}- Log.debug("更新双屏的layout libretroViewFrame:\(libretroViewFrame) top:\(topFrame) bottom:\(bottomFrame) layout: \(layout)")+ Log.debug("[updateDualScreenViews]\n skinframes: \(frames)\n libretroViewFrame: \(libretroViewFrame)\n topFrame: \(topFrame)\n bottomFrame: \(bottomFrame)\n absX: \(absX)\n absY: \(absY)\n scale: \(scale)\n scaleTopFrame: \(scaleTopFrame)\n scaleBottomFrame: \(scaleBottomFrame)\n layout: \(layout)")} else {//单屏幕let bufferframe = libretroViewFrame.applying(scaleTransform)- layout = "\(max(bufferframe.minX, 0)),\(max(bufferframe.minY, 0)),\(bufferframe.width),\(bufferframe.height),\(0),\(0),\(0),\(0),\(bufferframe.width),\(bufferframe.height)"- Log.debug("更新单屏的layout libretroViewFrame:\(libretroViewFrame) layout: \(layout)")+ layout = "\(max(bufferframe.minX, 0).rounded1()),\(max(bufferframe.minY, 0).rounded1()),\(bufferframe.width.rounded1()),\(bufferframe.height.rounded1()),\(0),\(0),\(0),\(0),\(bufferframe.width.rounded1()),\(bufferframe.height.rounded1())"+ Log.debug("[updateDualScreenViews]\n skinframes: \(frames)\n libretroViewFrame: \(libretroViewFrame)\n scale: \(scale)\n bufferframe: \(bufferframe)\n layout: \(layout)")}if manicGame.gameType == .ds {@@ -3530,7 +3540,7 @@ extension PlayViewController {pauseEmulationIfNeed()}Log.debug("amiibo正在搜索中")- FilesImporter.shared.presentImportController(supportedTypes: UTType.binTypes, allowsMultipleSelection: false) { [weak self] urls in+ FilesImporter.shared.presentImportController(supportedTypes: UTType.binTypes, allowsMultipleSelection: false, manualHandle: { [weak self] urls inguard let self = self else { return }self.resumeEmulationAndHandleAudio()UIView.hideAllAlert { [weak self] in@@ -3546,7 +3556,7 @@ extension PlayViewController {}}}- }+ }, in: hostingWindowScene)} else {Log.debug("amiibo没有搜索")UIView.makeToast(message: R.string.localizable.amiiboNotSearching())@@ -3662,7 +3672,7 @@ extension PlayViewController {private func snapShotFor3DS(topOnly: Bool = false) -> [UIImage]? {guard let controllerSkin = controllerView.controllerSkin as? ControllerSkin else { return nil }- guard let frames = controllerSkin.getFrames() else { return nil }+ guard let hostingWindow, let frames = controllerSkin.getFrames(window: hostingWindow) else { return nil }guard let touchGameViewFrame = frames.touchGameViewFrame else { return nil }let skinFrame = frames.skinFramelet mainGameViewFrame = frames.mainGameViewFrame@@ -3678,11 +3688,11 @@ extension PlayViewController {private func snapShotForDualScreen(topOnly: Bool = false, source: UIImage) -> [UIImage]? {guard let controllerSkin = controllerView.controllerSkin as? ControllerSkin else { return nil }- guard let frames = controllerSkin.getFrames() else { return nil }+ guard let hostingWindow, let frames = controllerSkin.getFrames(window: hostingWindow) else { return nil }guard let libretroViewFrame = getDualScreenViewFrame() else { return nil }var screenImage = source- if screenImage.scale != UIScreen.main.scale, let imageData = screenImage.pngData(), let scaleImage = UIImage(data: imageData, scale: UIScreen.main.scale) {+ if screenImage.scale != hostingWindow.screen.scale, let imageData = screenImage.pngData(), let scaleImage = UIImage(data: imageData, scale: hostingWindow.screen.scale) {screenImage = scaleImage}@@ -3861,7 +3871,7 @@ extension PlayViewController {guard let self else { return }toast.config.cardEdgeInsets = .zerotoast.config.cardCornerRadius = R.Size.CornerRadiusMedium- toast.config.cardMaxWidth = (R.Size.WindowSize.minDimension - 2*R.Size.ContentSpaceHuge) * scale+ toast.config.cardMaxWidth = (R.Size.ApplicationWindowSize.minDimension - 2*R.Size.ContentSpaceHuge) * scaletoast.config.cardMaxHeight = 64 * scaletoast.contentView.layerBorderColor = R.Color.Bordertoast.contentView.layerBorderWidth = 1@@ -4234,7 +4244,7 @@ extension PlayViewController {private func getDualScreenViewFrame() -> CGRect? {guard let controllerSkin = controllerView.controllerSkin as? ControllerSkin else { return nil }- guard let frames = controllerSkin.getFrames() else { return nil }+ guard let hostingWindow, let frames = controllerSkin.getFrames(window: hostingWindow) else { return nil }let skinframe = frames.skinFramelet topFrame = frames.mainGameViewFrameif let bottomFrame = frames.touchGameViewFrame {@@ -4274,7 +4284,7 @@ extension PlayViewController {}if let result = Prefference.defalut.getPrefference(kind: .flexBackground,- storeKey: .orientationKey(gameId: manicGame.id, isLandScape: UIDevice.isLandscape),+ storeKey: .orientationKey(gameId: manicGame.id, isLandScape: view.prefferedLayoutStyle == .landscape),bestEfforts: true),case let .flexBackground(bg) = result {backgroundImageView?.image = bg.imagediff --git a/ManicEmu/ManicEmu/Sources/Business/Play/Views/CheevosPopupView.swift b/ManicEmu/ManicEmu/Sources/Business/Play/Views/CheevosPopupView.swiftindex 9a59b083..ff868e13 100644--- a/ManicEmu/ManicEmu/Sources/Business/Play/Views/CheevosPopupView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Play/Views/CheevosPopupView.swift@@ -213,7 +213,7 @@ class CheevosPopupView: BaseView {view.isFocusable = trueview.allowsSelection = trueview.allowsMultipleSelection = false- view.contentInset = .insets(bottom: R.Size.ContentInsetBottom)+ view.contentInset = .insets(bottom: R.Size.ContentInsetBottom(window: hostingWindow))return view}()@@ -342,14 +342,14 @@ extension CheevosPopupView: ShowableView {var height = R.Size.SheetGrabberTopInset + R.Size.NavigationHeightheight += CGFloat(leaderBoards.count) * 64height += CGFloat(leaderBoards.count + 1) * R.Size.ContentSpaceMedium- height += R.Size.ContentInsetBottom+ height += R.Size.ContentInsetBottom(window: hostingWindow)return heightcase .progress, .challenge:var height = R.Size.SheetGrabberTopInset + R.Size.NavigationHeightheight += CGFloat(achievements.count) * R.Size.ItemHeightExtraLargeheight += CGFloat(achievements.count + 1) * R.Size.ContentSpaceMedium- height += R.Size.ContentInsetBottom+ height += R.Size.ContentInsetBottom(window: hostingWindow)return height}}diff --git a/ManicEmu/ManicEmu/Sources/Business/Purchase/Views/FeaturesCell.swift b/ManicEmu/ManicEmu/Sources/Business/Purchase/Views/FeaturesCell.swiftindex ab7dea82..35c1c727 100644--- a/ManicEmu/ManicEmu/Sources/Business/Purchase/Views/FeaturesCell.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Purchase/Views/FeaturesCell.swift@@ -10,7 +10,6 @@import Deviceclass FeaturesCell: UICollectionViewCell {- private var viewAlongsideTransitionNotification: Any? = nilprivate var titleLabel: UILabel = {let view = UILabel()@@ -28,11 +27,6 @@ class FeaturesCell: UICollectionViewCell {private var iconImageView: UIImageView = {let view = UIImageView()view.contentMode = .center- if Device.size().rawValue < Size.screen5_8Inch.rawValue {- view.transform = CGAffineTransform(scaleX: 0.6, y: 0.6)- } else if UIDevice.isPad, UIDevice.isLandscape {- view.transform = CGAffineTransform(scaleX: 0.65, y: 0.65)- }return view}()@@ -70,6 +64,19 @@ class FeaturesCell: UICollectionViewCell {override func layoutSubviews() {super.layoutSubviews()+ if Device.size().rawValue < Size.screen5_8Inch.rawValue {+ if prefferedLayoutStyle == .landscape {+ iconImageView.transform = CGAffineTransform(scaleX: 1, y: 1)+ } else {+ iconImageView.transform = CGAffineTransform(scaleX: 0.6, y: 0.6)+ }+ } else if UIDevice.isPad {+ if prefferedLayoutStyle == .landscape {+ iconImageView.transform = CGAffineTransform(scaleX: 0.65, y: 0.65)+ } else {+ iconImageView.transform = CGAffineTransform(scaleX: 1, y: 1)+ }+ }gradientMaskLayer.frame = self.boundsif enableAnimation {startAnimation()@@ -78,12 +85,6 @@ class FeaturesCell: UICollectionViewCell {}}- deinit {- if let viewAlongsideTransitionNotification {- NotificationCenter.default.removeObserver(viewAlongsideTransitionNotification)- }- }-override init(frame: CGRect) {super.init(frame: frame)@@ -151,27 +152,6 @@ class FeaturesCell: UICollectionViewCell {make.centerX.equalToSuperview()make.bottom.equalToSuperview().offset(-R.Size.ItemHeightMicro)}-- viewAlongsideTransitionNotification = NotificationCenter.default.addObserver(forName: R.NotificationName.ViewAlongsideTransition,- object: nil,- queue: .main,- using: { [weak self] _ in- guard let self else { return }- if Device.size().rawValue < Size.screen5_8Inch.rawValue {- if UIDevice.isLandscape {- self.iconImageView.transform = CGAffineTransform(scaleX: 1, y: 1)- } else {- self.iconImageView.transform = CGAffineTransform(scaleX: 0.6, y: 0.6)- }- } else if UIDevice.isPad {- if UIDevice.isLandscape {- self.iconImageView.transform = CGAffineTransform(scaleX: 0.65, y: 0.65)- } else {- self.iconImageView.transform = CGAffineTransform(scaleX: 1, y: 1)- }- }- })-}required init?(coder: NSCoder) {@@ -242,13 +222,14 @@ class FeaturesCell: UICollectionViewCell {stopAnimation()var offset: CGFloatlet animation = CABasicAnimation(keyPath: "position.x")+ let windowSize = hostingWindow?.size ?? R.Size.ApplicationWindowSizeif UIDevice.isPad {- offset = (UIDevice.isLandscape ? R.Size.WindowHeight * 0.9 * 9 / 16 : R.Size.WindowWidth * 0.6) - iconImageView.width+ offset = (prefferedLayoutStyle == .landscape ? windowSize.height * 0.9 * 9 / 16 : windowSize.width * 0.6) - iconImageView.width} else {- if UIDevice.isLandscape {- offset = R.Size.WindowWidth/2 - iconImageView.width+ if prefferedLayoutStyle == .landscape {+ offset = windowSize.width/2 - iconImageView.width} else {- offset = R.Size.WindowWidth - iconImageView.width+ offset = windowSize.width - iconImageView.width}}diff --git a/ManicEmu/ManicEmu/Sources/Business/Purchase/Views/PriceView.swift b/ManicEmu/ManicEmu/Sources/Business/Purchase/Views/PriceView.swiftindex 5133ae6a..7bbe7fb8 100644--- a/ManicEmu/ManicEmu/Sources/Business/Purchase/Views/PriceView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Purchase/Views/PriceView.swift@@ -21,7 +21,7 @@ class PriceView: BaseView {view.delegate = selfview.isFocusable = trueview.contentInset = .insets(top: R.Size.ContentSpaceHuge,- bottom: R.Size.ContentInsetBottom)+ bottom: R.Size.ContentInsetBottom(window: hostingWindow))return view}()@@ -128,7 +128,7 @@ extension PriceView: UICollectionViewDataSource {} else {//购买成功self?.needToClosePurchaseView?()- CheersView.makePurchaseCheers()+ CheersView.makePurchaseCheers(in: self?.hostingWindowScene)}}}diff --git a/ManicEmu/ManicEmu/Sources/Business/Purchase/Views/PurchaseView.swift b/ManicEmu/ManicEmu/Sources/Business/Purchase/Views/PurchaseView.swiftindex 791173ce..1bdaebd6 100644--- a/ManicEmu/ManicEmu/Sources/Business/Purchase/Views/PurchaseView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Purchase/Views/PurchaseView.swift@@ -76,7 +76,7 @@ class PurchaseView: BaseView {guard let self else { return }if isMember {self.didTapClose?()- CheersView.makePurchaseCheers()+ CheersView.makePurchaseCheers(in: self.hostingWindowScene)} else if isCompleted {Log.debug("兑换优惠成功")} else {@@ -119,12 +119,11 @@ class PurchaseView: BaseView {addSubview(featureView)featureView.featuresType = featuresTypeaddSubview(priceView)-- updateViewsConstraits()}override func layoutSubviews() {super.layoutSubviews()+ updateViewsConstraits()imageLayer.contents = R.image.game_cover_bg()?.scaled(toWidth: backgroundGradientView.width)?.cropped(to: backgroundGradientView.bounds).cgImageimageLayer.frame = CGRect(origin: .zero, size: backgroundGradientView.size)}@@ -135,7 +134,7 @@ class PurchaseView: BaseView {private func updateViewsConstraits() {backgroundGradientView.snp.remakeConstraints { make in- if UIDevice.isPhone, UIDevice.isLandscape {+ if UIDevice.isPhone, prefferedLayoutStyle == .landscape {make.top.equalToSuperview()make.leading.bottom.trailing.equalTo(featureView)} else {@@ -145,7 +144,7 @@ class PurchaseView: BaseView {}featureView.snp.remakeConstraints { make in- if UIDevice.isPhone, UIDevice.isLandscape {+ if UIDevice.isPhone, prefferedLayoutStyle == .landscape {make.top.equalToSuperview().offset(R.Size.NavigationHeight)make.leading.bottom.equalToSuperview()make.width.equalToSuperview().dividedBy(2)@@ -156,7 +155,7 @@ class PurchaseView: BaseView {}priceView.snp.remakeConstraints { make in- if UIDevice.isPhone, UIDevice.isLandscape {+ if UIDevice.isPhone, prefferedLayoutStyle == .landscape {make.top.equalToSuperview().offset(R.Size.NavigationHeight)make.bottom.trailing.equalToSuperview()make.leading.equalTo(featureView.snp.trailing)@@ -168,10 +167,3 @@ class PurchaseView: BaseView {}}}--extension PurchaseView: ViewTransition {- func viewAlongsideTransition() {- guard UIDevice.isPhone else { return }- updateViewsConstraits()- }-}diff --git a/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/Views/RetroAchievementListView.swift b/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/Views/RetroAchievementListView.swiftindex 2adcb211..ee214ab6 100644--- a/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/Views/RetroAchievementListView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/Views/RetroAchievementListView.swift@@ -22,7 +22,7 @@ class RetroAchievementListView: BaseView {view.showsVerticalScrollIndicator = falseview.dataSource = selfview.contentInset = .insets(top: 90,- bottom: R.Size.ContentInsetBottom)+ bottom: R.Size.ContentInsetBottom(window: hostingWindow))let blankView = BlankSlateEmptyView(image: .symbolImage(.gamecontrollerFill).applySymbolConfig(size: 70, color: R.Color.LabelSecondary), title: R.string.localizable.achievementsNotSupport(game.displayName))blankView.label.isHidden = trueview.blankSlateView = blankViewdiff --git a/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/Views/RetroAchievementsDetailView.swift b/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/Views/RetroAchievementsDetailView.swiftindex 4c111a10..44eb0bf6 100644--- a/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/Views/RetroAchievementsDetailView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/Views/RetroAchievementsDetailView.swift@@ -237,7 +237,7 @@ class RetroAchievementsDetailView: BaseView {UIView.makeLoading()self.generateShareImage(achievement: achievement) { image inUIView.hideLoading()- ShareManager.shareImage(image: image)+ ShareManager.shareImage(image: image, in: self.hostingWindowScene)self.shareContentView?.removeFromSuperview()self.shareContentView = nil}@@ -267,8 +267,8 @@ class RetroAchievementsDetailView: BaseView {contentView.addSubview(shareImageView)shareImageView.snp.makeConstraints { make inmake.center.equalToSuperview()- make.size.equalTo(CGSize(width: R.Size.WindowSize.minDimension,- height: R.Size.WindowSize.maxDimension))+ make.size.equalTo(CGSize(width: R.Size.ApplicationWindowSize.minDimension,+ height: R.Size.ApplicationWindowSize.maxDimension))}let maskView = UIView()diff --git a/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/Views/RetroAchievementsLaunchView.swift b/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/Views/RetroAchievementsLaunchView.swiftindex d320a1b8..e158061b 100644--- a/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/Views/RetroAchievementsLaunchView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/Views/RetroAchievementsLaunchView.swift@@ -128,7 +128,7 @@ class RetroAchievementsLaunchView: BaseView {if showClose {make.top.equalToSuperview().offset(R.Size.SheetGrabberTopInset)} else {- make.top.equalToSuperview().offset(R.Size.ContentInsetTop)+ make.top.equalToSuperview().offset(R.Size.ContentInsetTop(window: hostingWindow))}make.leading.trailing.equalTo(safeAreaLayoutGuide)make.height.equalTo(R.Size.ItemHeightMedium)diff --git a/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/Views/RetroAchievementsListCell.swift b/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/Views/RetroAchievementsListCell.swiftindex b83aa389..af07f04b 100644--- a/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/Views/RetroAchievementsListCell.swift+++ b/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/Views/RetroAchievementsListCell.swift@@ -192,11 +192,12 @@ class RetroAchievementsListCell: UICollectionViewCell {}private func createLayout() -> UICollectionViewLayout {- let layout = UICollectionViewCompositionalLayout { sectionIndex, env in+ let layout = UICollectionViewCompositionalLayout { [weak self] sectionIndex, env in+ guard let self else { return nil }var column = 4.0- if UIDevice.isPhone && UIDevice.isLandscape {+ if UIDevice.isPhone && self.prefferedLayoutStyle == .landscape {column = 8.0- } else if UIDevice.isPad && UIDevice.isLandscape {+ } else if UIDevice.isPad && self.prefferedLayoutStyle == .landscape {column = 6.0}let cellSize = (env.container.contentSize.width - R.Size.ContentSpaceHuge*2 - R.Size.ContentSpaceSmall*(column-1))/columndiff --git a/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/Views/RetroAchievementsLoginView.swift b/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/Views/RetroAchievementsLoginView.swiftindex 908397a8..cfdb557f 100644--- a/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/Views/RetroAchievementsLoginView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/Views/RetroAchievementsLoginView.swift@@ -80,7 +80,7 @@ class RetroAchievementsLoginView: BaseView {view.delegate = selfview.isFocusable = trueview.contentInset = .insets(top: 90,- bottom: R.Size.ContentInsetBottom)+ bottom: R.Size.ContentInsetBottom(window: hostingWindow))return view}()diff --git a/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/Views/RetroAchievementsProfileView.swift b/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/Views/RetroAchievementsProfileView.swiftindex a212c8ea..c0b14507 100644--- a/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/Views/RetroAchievementsProfileView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/Views/RetroAchievementsProfileView.swift@@ -11,6 +11,8 @@ import RealmSwiftclass RetroAchievementsProfileView: BaseView {class DetailView: BaseView {+ var didLayoutChange: (() -> Bool)? = nil+private static let avatarSize = 80.0class UnlockedView: BaseView {@@ -253,15 +255,19 @@ class RetroAchievementsProfileView: BaseView {}addSubviews([enableGlobalCardView, enableGlobalHardcoreCardView, unlockedView])- updateViewsConstraits()}@MainActor required init?(coder: NSCoder) {fatalError("init(coder:) has not been implemented")}+ override func layoutSubviews() {+ super.layoutSubviews()+ updateViewsConstraits()+ }+func updateViewsConstraits() {- if UIDevice.isLandscape {+ if didLayoutChange?() ?? false {enableGlobalCardView.snp.remakeConstraints { make inmake.height.equalTo(R.Size.CardHeight)make.leading.equalToSuperview()@@ -321,6 +327,10 @@ class RetroAchievementsProfileView: BaseView {view.didTapLogout = { [weak self] inself?.logoutSuccess?()}+ view.didLayoutChange = { [weak self] in+ guard let self else { return false }+ return self.prefferedLandscapeStyle+ }return view}()@@ -377,13 +387,21 @@ class RetroAchievementsProfileView: BaseView {private var retroProfile = AchievementsProfile()private var detailViewHeight: CGFloat {- UIDevice.isLandscape ? 327 : 496.7+ prefferedLandscapeStyle ? 327 : 496.7}var logoutSuccess: (()->Void)? = nilprivate var showAsSheet: Bool+ private var prefferedLandscapeStyle: Bool {+ if showAsSheet {+ return prefferedLayoutStyle == .landscape+ } else {+ return width > 600+ }+ }+init(username: String, showAsSheet: Bool) {self.username = usernameself.showAsSheet = showAsSheet@@ -473,7 +491,7 @@ class RetroAchievementsProfileView: BaseView {return ASListPage(sections: sections,backgroundColor: .clear,listInsets: .insets(top: R.Size.NavigationHeight - R.Size.ContentSpaceSmall,- bottom: R.Size.ContentInsetBottom + (!showAsSheet ? R.Size.HomeTabBarSize.height + R.Size.ContentSpaceMedium : 0)))+ bottom: R.Size.ContentInsetBottom(window: hostingWindow) + (!showAsSheet ? R.Size.HomeTabBarSize.height + R.Size.ContentSpaceMedium : 0)))}private func updateDatas() {diff --git a/ManicEmu/ManicEmu/Sources/Business/Settings/ViewControllers/SettingsViewController.swift b/ManicEmu/ManicEmu/Sources/Business/Settings/ViewControllers/SettingsViewController.swiftindex c4905978..2d720df9 100644--- a/ManicEmu/ManicEmu/Sources/Business/Settings/ViewControllers/SettingsViewController.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Settings/ViewControllers/SettingsViewController.swift@@ -50,32 +50,62 @@ class SettingsViewController: BaseViewController {make.edges.equalToSuperview()}}- settingsListView.snp.makeConstraints { make in++ let themeView = ThemeSettingView(showClose: false)+ detailContentView.addSubview(themeView)+ themeView.snp.makeConstraints { make in+ make.edges.equalToSuperview()+ }+ }+ }++ override func viewDidLayoutSubviews() {+ super.viewDidLayoutSubviews()+ if UIDevice.isPad, hostingWindow != nil {+ updateViewsForIpad()+ }+ }++ private func updateViewsForIpad() {+ guard UIDevice.isPad else { return }+ guard let hostingWindow else { return }+ if view.isWindowHasEnoughSpaceforIpadMultiColumnLayout {+ let sideMenuWidth = R.Size.SideMenuWidth(window: hostingWindow)*1.2+ settingsListView.snp.remakeConstraints { make inmake.leading.top.bottom.equalToSuperview()- make.width.equalTo(R.Size.SideMenuWidth*1.2)+ if sideMenuWidth <= hostingWindow.width/2 {+ make.width.equalTo(sideMenuWidth)+ } else {+ make.width.equalTo(hostingWindow.width/2)+ }}+ cornerMaskViewForiPad.removeFromSuperview()view.addSubview(cornerMaskViewForiPad)- cornerMaskViewForiPad.snp.makeConstraints { make in+ cornerMaskViewForiPad.snp.remakeConstraints { make inmake.edges.equalTo(settingsListView)}+ detailContentView.removeFromSuperview()view.addSubview(detailContentView)- detailContentView.snp.makeConstraints { make in+ detailContentView.snp.remakeConstraints { make inmake.top.trailing.bottom.equalToSuperview()make.leading.equalTo(settingsListView.snp.trailing).offset(R.Size.ContentSpaceMedium)}+ detailMaskViewForiPad.removeFromSuperview()view.addSubview(detailMaskViewForiPad)- detailMaskViewForiPad.snp.makeConstraints { make in+ detailMaskViewForiPad.snp.remakeConstraints { make inmake.edges.equalTo(detailContentView)}-- let themeView = ThemeSettingView(showClose: false)- detailContentView.addSubview(themeView)- themeView.snp.makeConstraints { make in- make.edges.equalToSuperview()+ } else {+ settingsListView.snp.remakeConstraints { make in+ make.top.bottom.equalToSuperview()+ make.leading.trailing.equalTo(view.safeAreaLayoutGuide)}+ cornerMaskViewForiPad.removeFromSuperview()+ detailContentView.removeFromSuperview()+ detailMaskViewForiPad.removeFromSuperview()}}}diff --git a/ManicEmu/ManicEmu/Sources/Business/Settings/Views/BIOSCollectionViewCell.swift b/ManicEmu/ManicEmu/Sources/Business/Settings/Views/BIOSCollectionViewCell.swiftindex 1866b72e..38555733 100644--- a/ManicEmu/ManicEmu/Sources/Business/Settings/Views/BIOSCollectionViewCell.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Settings/Views/BIOSCollectionViewCell.swift@@ -231,7 +231,7 @@ class BIOSCollectionViewCell: UICollectionViewCell {itemView.isHidden = falseitemView.button.onTap {func importFromFiles() {- FilesImporter.shared.presentImportController(supportedTypes: UTType.binTypes, allowsMultipleSelection: true) { urls in+ FilesImporter.shared.presentImportController(supportedTypes: UTType.binTypes, allowsMultipleSelection: true, manualHandle: { urls inUIView.makeLoading()DispatchQueue.global().async {var matchs = [(url: URL, fileName: String)]()@@ -289,7 +289,7 @@ class BIOSCollectionViewCell: UICollectionViewCell {}}}- }+ }, in: self.hostingWindowScene)}if gameType == ._3ds {@@ -353,7 +353,7 @@ class BIOSCollectionViewCell: UICollectionViewCell {if path.pathExtension.lowercased() == "app", let tid = pathToTid(path) {if R.Numbers.ThreeDSHomeMenuIdentifiers.contains(where: { $0 == tid }) {//识别到了3dS的home menu- FilesImporter.importFiles(urls: [URL(fileURLWithPath: path)], silentMode: true)+ FilesImporter.importFiles(urls: [URL(fileURLWithPath: path)], silentMode: true, in: hostingWindowScene)}}diff --git a/ManicEmu/ManicEmu/Sources/Business/Settings/Views/BIOSSelectionView.swift b/ManicEmu/ManicEmu/Sources/Business/Settings/Views/BIOSSelectionView.swiftindex ec9154f7..bdc42563 100644--- a/ManicEmu/ManicEmu/Sources/Business/Settings/Views/BIOSSelectionView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Settings/Views/BIOSSelectionView.swift@@ -165,13 +165,13 @@ class BIOSSelectionView: BaseView {titleIcon: .symbolImage(R.image.bios_iconSymbols()))navigation.enableClose = showClose- let listInsetBottom = (UIDevice.isPad && !showClose) ? R.Size.ContentInsetBottom + R.Size.HomeTabBarSize.height + R.Size.ContentSpaceMedium : 0+ let listInsetBottom = (UIDevice.isPad && !showClose) ? R.Size.ContentInsetBottom(window: hostingWindow) + R.Size.HomeTabBarSize.height + R.Size.ContentSpaceMedium : 0return ASListPage(navigation: navigation,sections: sections,backgroundColor: .clear,listInsets: .insets(bottom: listInsetBottom),- pageInsets: .insets(top: showClose ? R.Size.SheetGrabberTopInset : R.Size.ContentInsetTop))+ pageInsets: .insets(top: showClose ? R.Size.SheetGrabberTopInset : R.Size.ContentInsetTop(window: hostingWindow)))}private func getCell(item: BIOSItem) -> ASListPage.Cell {@@ -301,7 +301,7 @@ class BIOSSelectionView: BaseView {if let indexPath = action.listPageValue?.normalItemValue?.indexPath,indexPath.section < regions.count {let region = regions[indexPath.section]- FilesImporter.shared.presentImportController(supportedTypes: UTType.binTypes, allowsMultipleSelection: false) { urls in+ FilesImporter.shared.presentImportController(supportedTypes: UTType.binTypes, allowsMultipleSelection: false, manualHandle: { urls inUIView.makeLoading()DispatchQueue.global().async {// Match IPL.bin case-insensitively; always write as IPL.bin.@@ -336,7 +336,7 @@ class BIOSSelectionView: BaseView {}}}- }+ }, in: self?.hostingWindowScene)return .none}return .dismiss()@@ -345,7 +345,8 @@ class BIOSSelectionView: BaseView {private func importBios(gameType: GameType) {func importFromFiles() {- FilesImporter.shared.presentImportController(supportedTypes: UTType.binTypes, allowsMultipleSelection: true) { urls in+ FilesImporter.shared.presentImportController(supportedTypes: UTType.binTypes, allowsMultipleSelection: true, manualHandle: { [weak self] urls in+ guard let self else { return }UIView.makeLoading()DispatchQueue.global().async { [weak self] inguard let self else { return }@@ -442,7 +443,7 @@ class BIOSSelectionView: BaseView {}}}- }+ }, in: hostingWindowScene)}if gameType == ._3ds {@@ -500,7 +501,7 @@ class BIOSSelectionView: BaseView {if path.pathExtension.lowercased() == "app", let tid = pathToTid(path) {if R.Numbers.ThreeDSHomeMenuIdentifiers.contains(where: { $0 == tid }) {//识别到了3dS的home menu- FilesImporter.importFiles(urls: [URL(fileURLWithPath: path)], silentMode: true)+ FilesImporter.importFiles(urls: [URL(fileURLWithPath: path)], silentMode: true, in: hostingWindowScene)}}diff --git a/ManicEmu/ManicEmu/Sources/Business/Settings/Views/ColorPickerView.swift b/ManicEmu/ManicEmu/Sources/Business/Settings/Views/ColorPickerView.swiftindex 26e11aa5..c4e12f7d 100644--- a/ManicEmu/ManicEmu/Sources/Business/Settings/Views/ColorPickerView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Settings/Views/ColorPickerView.swift@@ -10,13 +10,13 @@import ChromaColorPickerclass ColorPickerView: BaseView {- private static var colorPickerSize: CGSize {- if UIDevice.isPhone, UIDevice.isLandscape {+ private var colorPickerSize: CGSize {+ if UIDevice.isPhone, prefferedLayoutStyle == .landscape {return CGSize(150)}return CGSize(290)}- private let colorPicker = ChromaColorPicker(frame: CGRect(origin: .zero, size: ColorPickerView.colorPickerSize))+ private let colorPicker = ChromaColorPicker(frame: CGRect(origin: .zero, size: CGSize(290)))private let brightnessSlider = ChromaBrightnessSlider()private let colorView = ThemeColorCollectionViewCell.ColorView()private var textField: UITextField = {@@ -51,7 +51,7 @@ class ColorPickerView: BaseView {colorPicker.snp.makeConstraints { make inmake.top.equalToSuperview()make.centerX.equalToSuperview()- make.size.equalTo(ColorPickerView.colorPickerSize)+ make.size.equalTo(colorPickerSize)}view.addSubview(brightnessSlider)@@ -189,18 +189,18 @@ class ColorPickerView: BaseView {colorPickerContainerView.snp.makeConstraints { make inmake.top.equalTo(navigationView.snp.bottom)make.leading.trailing.equalToSuperview()- make.bottom.equalToSuperview().inset(R.Size.ContentInsetBottom + R.Size.ButtonExtraLarge + R.Size.ContentSpaceLarge)+ make.bottom.equalToSuperview().inset(R.Size.ContentInsetBottom(window: hostingWindow) + R.Size.ButtonExtraLarge + R.Size.ContentSpaceLarge)}addSubview(saveButton)saveButton.snp.makeConstraints { make in- if UIDevice.isPad || (UIDevice.isPhone && UIDevice.isLandscape) {+ if UIDevice.isPad || (UIDevice.isPhone && proHUDLayoutStyle() == .landscape) {make.width.equalTo(R.Size.ButtonMaxWidth)make.centerX.equalToSuperview()} else {make.leading.trailing.equalTo(safeAreaLayoutGuide).inset(R.Size.ContentSpaceHuge)}- make.bottom.equalToSuperview().inset(R.Size.ContentInsetBottom)+ make.bottom.equalToSuperview().inset(R.Size.ContentInsetBottom(window: hostingWindow))make.height.equalTo(R.Size.ButtonExtraLarge)}}@@ -232,7 +232,7 @@ extension ColorPickerView: ShowableView {}var prefferdConstraintHeight: CGFloat? {- if UIDevice.isPhone, UIDevice.isPortrait {+ if UIDevice.isPhone, proHUDLayoutStyle() == .portrait {return 582}return R.Size.SheetWindowMaxSize.height@@ -249,11 +249,11 @@ extension ColorPickerView: ViewTransition {func viewAlongsideTransition() {if UIDevice.isPhone {colorPicker.snp.updateConstraints { make in- make.size.equalTo(ColorPickerView.colorPickerSize)+ make.size.equalTo(colorPickerSize)}saveButton.snp.updateConstraints { make in- make.bottom.equalToSuperview().inset(R.Size.ContentInsetBottom)+ make.bottom.equalToSuperview().inset(R.Size.ContentInsetBottom(window: hostingWindow))}}diff --git a/ManicEmu/ManicEmu/Sources/Business/Settings/Views/GlobalCoreSwitchView.swift b/ManicEmu/ManicEmu/Sources/Business/Settings/Views/GlobalCoreSwitchView.swiftindex 796fdfb0..13c4b6dc 100644--- a/ManicEmu/ManicEmu/Sources/Business/Settings/Views/GlobalCoreSwitchView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Settings/Views/GlobalCoreSwitchView.swift@@ -30,8 +30,8 @@ class GlobalCoreSwitchView: BaseView {let view = ASListPageView(ASListPage(navigation: navigation,sections: sections,backgroundColor: .clear,- listInsets: .insets(bottom: UIDevice.isPad ? R.Size.ContentInsetBottom + R.Size.HomeTabBarSize.height + R.Size.ContentSpaceLarge : R.Size.ContentInsetBottom),- pageInsets: .insets(top: showClose ? R.Size.SheetGrabberTopInset : R.Size.ContentInsetTop)))+ listInsets: .insets(bottom: UIDevice.isPad ? R.Size.ContentInsetBottom(window: hostingWindow) + R.Size.HomeTabBarSize.height + R.Size.ContentSpaceLarge : R.Size.ContentInsetBottom(window: hostingWindow)),+ pageInsets: .insets(top: showClose ? R.Size.SheetGrabberTopInset : R.Size.ContentInsetTop(window: hostingWindow))))view.didActionOccurred = { [weak self] listAction inguard let self else { return }if let (listAndexPath, cellData, _) = listAction.normalItemValue {diff --git a/ManicEmu/ManicEmu/Sources/Business/Settings/Views/JITSettingView.swift b/ManicEmu/ManicEmu/Sources/Business/Settings/Views/JITSettingView.swiftindex c6fb090b..2bf7209d 100644--- a/ManicEmu/ManicEmu/Sources/Business/Settings/Views/JITSettingView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Settings/Views/JITSettingView.swift@@ -268,13 +268,13 @@ class JITSettingView: BaseView {]#endif- let listInsetBottom = (UIDevice.isPad && !showClose) ? R.Size.ContentInsetBottom + R.Size.HomeTabBarSize.height + R.Size.ContentSpaceMedium : 0+ let listInsetBottom = (UIDevice.isPad && !showClose) ? R.Size.ContentInsetBottom(window: hostingWindow) + R.Size.HomeTabBarSize.height + R.Size.ContentSpaceMedium : 0return ASListPage(navigation: navigation,sections: sections,backgroundColor: .clear,listInsets: .insets(bottom: listInsetBottom),- pageInsets: .insets(top: showClose ? R.Size.SheetGrabberTopInset : R.Size.ContentInsetTop))+ pageInsets: .insets(top: showClose ? R.Size.SheetGrabberTopInset : R.Size.ContentInsetTop(window: hostingWindow)))}#if SIDE_LOAD@@ -334,7 +334,7 @@ class JITSettingView: BaseView {}private func importPairingTapped() {- StikJITManager.shared.presentPairingFilePicker { [weak self] ok, error in+ StikJITManager.shared.presentPairingFilePicker(in: hostingWindowScene) { [weak self] ok, error inif let error {UIView.makeToast(message: error)} else if ok, StikJITManager.shared.hasPairingFile, StikJITManager.shared.isBuiltInAvailable {diff --git a/ManicEmu/ManicEmu/Sources/Business/Settings/Views/SettingsAdventureCardView.swift b/ManicEmu/ManicEmu/Sources/Business/Settings/Views/SettingsAdventureCardView.swiftindex 8b997171..fe2502c1 100644--- a/ManicEmu/ManicEmu/Sources/Business/Settings/Views/SettingsAdventureCardView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Settings/Views/SettingsAdventureCardView.swift@@ -165,7 +165,7 @@ class SettingsAdventureCardView: BaseView {if let data = Settings.defalut.avatar?.storedData(), let image = UIImage(data: data) {sources.append(.editImage(image))}- ImageFetcher.showCommonFetcher(sources: sources) { [weak self] image, _ in+ ImageFetcher.showCommonFetcher(sources: sources, in: hostingWindowScene) { [weak self] image, _ inguard let self, let image else { return }self.persistAvatar(image)}diff --git a/ManicEmu/ManicEmu/Sources/Business/Settings/Views/SettingsListView.swift b/ManicEmu/ManicEmu/Sources/Business/Settings/Views/SettingsListView.swiftindex 549dea3a..17ab9b6c 100644--- a/ManicEmu/ManicEmu/Sources/Business/Settings/Views/SettingsListView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Settings/Views/SettingsListView.swift@@ -169,7 +169,7 @@ class SettingsListView: BaseView {}private func getNavigation() -> ASListPage.Navigation? {- if UIDevice.isPhone, UIDevice.isLandscape {+ if UIDevice.isPhone, prefferedLayoutStyle == .landscape {return nil}var navigationText = ASText.extraLargeText(R.string.localizable.tabbarTitleSettings())@@ -187,7 +187,7 @@ class SettingsListView: BaseView {case .top:sections.append(ASListPage.Section(cells: [.custom(topView)],decoration: .init(enable: false),- itemLayout: .fixedHeight((UIDevice.isPhone && UIDevice.isLandscape) ? 165 : 301)))+ itemLayout: .fixedHeight((UIDevice.isPhone && prefferedLayoutStyle == .landscape) ? 165 : 301)))case .general, .advance, .support, .others:var header: ASListPage.Supplementary? = nil@@ -211,7 +211,7 @@ class SettingsListView: BaseView {let listBottomInset = R.Size.ContentSpaceLarge + R.Size.HomeTabBarSize.height + R.Size.ContentSpaceLargelet pageTopInset: CGFloat- pageTopInset = UIDevice.isPhone && UIDevice.isLandscape ? 0 : R.Size.ContentInsetTop+ pageTopInset = UIDevice.isPhone && prefferedLayoutStyle == .landscape ? 0 : R.Size.ContentInsetTop(window: hostingWindow)return ASListPage(navigation: getNavigation(),sections: sections,backgroundColor: .clear,@@ -222,7 +222,7 @@ class SettingsListView: BaseView {private func showMemberShip(featuresType: FeaturesType = .advance) {#if !SIDE_LOAD- topViewController()?.present(PurchaseViewController(featuresType: featuresType), animated: true)+ topViewController(in: hostingWindowScene)?.present(PurchaseViewController(featuresType: featuresType), animated: true)#endif}@@ -271,37 +271,38 @@ class SettingsListView: BaseView {case .general, .advance, .support, .others:if let item = items[sectionIndex]?[indexPath.row] {+ guard let hostingWindow else { return }switch item.type {case .retro:- if UIDevice.isPad {+ if isWindowHasEnoughSpaceforIpadMultiColumnLayout {didTapDetailView?(RetroAchievementsLaunchView(loginedAction: .jumpProfile, showClose: false))} else {RetroAchievementsLaunchView.show(loginedAction: .jumpProfile)}case .onlinePlay:- if UIDevice.isPad {+ if isWindowHasEnoughSpaceforIpadMultiColumnLayout {didTapDetailView?(OnlinePlaySettingView(showClose: false))} else {OnlinePlaySettingView.show()}case .bios:- if UIDevice.isPad {+ if isWindowHasEnoughSpaceforIpadMultiColumnLayout {didTapDetailView?(BIOSSelectionView(showClose: false))} else {BIOSSelectionView.show()}case .theme:- if UIDevice.isPad {+ if isWindowHasEnoughSpaceforIpadMultiColumnLayout {didTapDetailView?(ThemeSettingView(showClose: false))} else {ThemeSettingView.show()}case .FAQ:- if UIDevice.isPad {+ if isWindowHasEnoughSpaceforIpadMultiColumnLayout {didTapDetailView?(ASWebView(url: R.URLs.FAQ, showClose: false))} else {ASWebView.show(url: R.URLs.FAQ)@@ -312,13 +313,13 @@ class SettingsListView: BaseView {let mailController = MFMailComposeViewController()mailController.setToRecipients([R.Strings.SupportEmail])mailController.mailComposeDelegate = self- topViewController(appController: true)?.present(mailController, animated: true)+ topApplicationViewController()?.present(mailController, animated: true)} else {UIView.makeToast(message: R.string.localizable.noEmailSetting())}case .shareApp:- ShareManager.shareApp(senderForIpad: UIDevice.isPad ? self : nil)+ ShareManager.shareApp(senderForIpad: UIDevice.isPad ? self : nil, in: hostingWindowScene)case .qq:UIApplication.shared.open(R.URLs.JoinQQ)@@ -345,35 +346,35 @@ class SettingsListView: BaseView {}case .userAgreement:- if UIDevice.isPad {+ if isWindowHasEnoughSpaceforIpadMultiColumnLayout {didTapDetailView?(ASWebView(url: R.URLs.TermsOfUse, showClose: false))} else {ASWebView.show(url: R.URLs.TermsOfUse)}case .privacyPolicy:- if UIDevice.isPad {+ if isWindowHasEnoughSpaceforIpadMultiColumnLayout {didTapDetailView?(ASWebView(url: R.URLs.PrivacyPolicy, showClose: false))} else {ASWebView.show(url: R.URLs.PrivacyPolicy)}case .about:- if UIDevice.isPad {+ if isWindowHasEnoughSpaceforIpadMultiColumnLayout {didTapDetailView?(ASWebView(url: R.URLs.AboutUS, showClose: false))} else {ASWebView.show(url: R.URLs.AboutUS)}case .triggerPro:- if UIDevice.isPad {+ if isWindowHasEnoughSpaceforIpadMultiColumnLayout {didTapDetailView?(TriggerProManageView(showClose: false))} else {TriggerProManageView.show()}case .skin:- if UIDevice.isPad {+ if isWindowHasEnoughSpaceforIpadMultiColumnLayout {didTapDetailView?(SkinSettingsView(showClose: false))} else {SkinSettingsView.show()@@ -381,7 +382,7 @@ class SettingsListView: BaseView {case .iCloud:#if !SIDE_LOAD- if UIDevice.isPad {+ if isWindowHasEnoughSpaceforIpadMultiColumnLayout {didTapDetailView?(ICloudSettingView(showClose: false))} else {ICloudSettingView.show()@@ -389,14 +390,14 @@ class SettingsListView: BaseView {#endifcase .jit:- if UIDevice.isPad {+ if isWindowHasEnoughSpaceforIpadMultiColumnLayout {didTapDetailView?(JITSettingView(showClose: false))} else {JITSettingView.show()}case .shaders:- if UIDevice.isPad {+ if isWindowHasEnoughSpaceforIpadMultiColumnLayout {didTapDetailView?(ShaderListView(initType: .normal, showClose: false))} else {ShaderListView.show(initType: .normal)@@ -406,7 +407,7 @@ class SettingsListView: BaseView {UIApplication.shared.open(R.URLs.PlayCasePromo)case .globalCoreSwitch:- if UIDevice.isPad {+ if isWindowHasEnoughSpaceforIpadMultiColumnLayout {didTapDetailView?(GlobalCoreSwitchView(showClose: false))} else {GlobalCoreSwitchView.show()@@ -456,8 +457,15 @@ class SettingsListView: BaseView {Settings.defalut.updateExtra(key: ExtraKey.skinSoundEffects.rawValue, value: value)case .coverScraping:- if UIDevice.isPad {- didTapDetailView?(GameCoverScrapingView(showClose: false))+ if isWindowHasEnoughSpaceforIpadMultiColumnLayout {+ let realm = Database.realm+ let games = realm.objects(Game.self).where({ !$0.isDeleted })+ if games.count > 0 {+ didTapDetailView?(GameCoverScrapingView(games: Array(games),+ showClose: false))+ } else {+ UIView.makeToast(message: R.string.localizable.transferPakNoGames())+ }} else {GameCoverScrapingView.show()}diff --git a/ManicEmu/ManicEmu/Sources/Business/Settings/Views/SettingsTopView.swift b/ManicEmu/ManicEmu/Sources/Business/Settings/Views/SettingsTopView.swiftindex a9cad016..0f63f156 100644--- a/ManicEmu/ManicEmu/Sources/Business/Settings/Views/SettingsTopView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Settings/Views/SettingsTopView.swift@@ -21,7 +21,7 @@ class SettingsTopView: BaseView {}func updateViewsConstraints() {- if UIDevice.isPhone, UIDevice.isLandscape {+ if UIDevice.isPhone, prefferedLayoutStyle == .landscape {membershipView.snp.remakeConstraints { make inmake.leading.top.bottom.equalToSuperview()}diff --git a/ManicEmu/ManicEmu/Sources/Business/Settings/Views/SymbianDeviceView.swift b/ManicEmu/ManicEmu/Sources/Business/Settings/Views/SymbianDeviceView.swiftindex 1a063952..b199959c 100644--- a/ManicEmu/ManicEmu/Sources/Business/Settings/Views/SymbianDeviceView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Settings/Views/SymbianDeviceView.swift@@ -84,7 +84,7 @@ class SymbianDeviceView: BaseView {view.dataSource = selfview.delegate = selfview.isFocusable = true- view.contentInset = .insets(bottom: R.Size.ContentInsetBottom)+ view.contentInset = .insets(bottom: R.Size.ContentInsetBottom(window: hostingWindow))view.blankSlateView = BlankSlateEmptyView(title: R.string.localizable.noSystemApp())return view}()@@ -168,7 +168,7 @@ class SymbianDeviceView: BaseView {}game.safeMode = truegame.symbianSystemApp = SymbianSystemApp(uid: symbianGame.uidString, deviceIndex: device.index, os: SymbianOS.getOS(by: device))- PlayViewController.startGame(game: game)+ PlayViewController.startGame(game: game, in: hostingWindowScene)}}diff --git a/ManicEmu/ManicEmu/Sources/Business/Settings/Views/SymbianFirmwareView.swift b/ManicEmu/ManicEmu/Sources/Business/Settings/Views/SymbianFirmwareView.swiftindex 5c17a898..bdeb8ec3 100644--- a/ManicEmu/ManicEmu/Sources/Business/Settings/Views/SymbianFirmwareView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Settings/Views/SymbianFirmwareView.swift@@ -147,7 +147,7 @@ class SymbianFirmwareView: BaseView {guard devices.count == 0 else { return nil }return .init(title: R.string.localizable.noFirmware(),detail: R.string.localizable.symbianOSFirmwareDesc(),- layoutInsets: .insets(bottom: R.Size.ContentInsetBottom + R.Size.ButtonExtraLarge))+ layoutInsets: .insets(bottom: R.Size.ContentInsetBottom(window: hostingWindow) + R.Size.ButtonExtraLarge))}private func getNavigation() -> ASListPage.Navigation {@@ -273,7 +273,8 @@ class SymbianFirmwareView: BaseView {updation: ASSheetView.ASSheetViewUpdation?) {guard let utType = UTType(filenameExtension: fileExtension) else { return }FilesImporter.shared.presentImportController(supportedTypes: [utType],- allowsMultipleSelection: false) { [weak self] urls in+ allowsMultipleSelection: false,+ manualHandle: { [weak self] urls inguard let self, let url = urls.first else { return }let previous = fileExtension == "rom" ? self.pendingRomURL : self.pendingRpkgURLguard let copied = self.copyImportFile(url, replacing: previous) else {@@ -286,7 +287,7 @@ class SymbianFirmwareView: BaseView {self.pendingRpkgURL = copied}updation?(.listPage(self.makeAddFirmwareListPage()))- }+ }, in: hostingWindowScene)}private func handleInstallFirmware() -> ASSheetView.ActionResult {diff --git a/ManicEmu/ManicEmu/Sources/Business/Settings/Views/ThemeSettingView.swift b/ManicEmu/ManicEmu/Sources/Business/Settings/Views/ThemeSettingView.swiftindex 5cd06f6c..68868ab9 100644--- a/ManicEmu/ManicEmu/Sources/Business/Settings/Views/ThemeSettingView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Settings/Views/ThemeSettingView.swift@@ -67,7 +67,7 @@ class ThemeSettingView: BaseView {view.dragDelegate = selfview.dropDelegate = selfview.contentInset = .insets(top: R.Size.ContentSpaceSmall,- bottom: UIDevice.isPad ? (R.Size.ContentInsetBottom + R.Size.HomeTabBarSize.height + R.Size.ContentSpaceLarge) : R.Size.ContentInsetBottom)+ bottom: UIDevice.isPad ? (R.Size.ContentInsetBottom(window: hostingWindow) + R.Size.HomeTabBarSize.height + R.Size.ContentSpaceLarge) : R.Size.ContentInsetBottom(window: hostingWindow))return view}()@@ -94,7 +94,7 @@ class ThemeSettingView: BaseView {if showClose {make.top.equalToSuperview().offset(R.Size.SheetGrabberTopInset)} else {- make.top.equalToSuperview().offset(R.Size.ContentInsetTop)+ make.top.equalToSuperview().offset(R.Size.ContentInsetTop(window: hostingWindow))}make.height.equalTo(R.Size.NavigationHeight)}diff --git a/ManicEmu/ManicEmu/Sources/Business/Settings/Views/iCloudSettingView.swift b/ManicEmu/ManicEmu/Sources/Business/Settings/Views/iCloudSettingView.swiftindex 364e55d4..f2c79226 100644--- a/ManicEmu/ManicEmu/Sources/Business/Settings/Views/iCloudSettingView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Settings/Views/iCloudSettingView.swift@@ -100,12 +100,12 @@ class ICloudSettingView: BaseView {], footer: .texts([.smallText(R.string.localizable.iCloudRepairSyncDesc(), numberOfLines: 0)], pin: false)))}- let listInsetBottom = (UIDevice.isPad && !showClose) ? R.Size.ContentInsetBottom + R.Size.HomeTabBarSize.height + R.Size.ContentSpaceMedium : 0+ let listInsetBottom = (UIDevice.isPad && !showClose) ? R.Size.ContentInsetBottom(window: hostingWindow) + R.Size.HomeTabBarSize.height + R.Size.ContentSpaceMedium : 0return ASListPage(navigation: navigation,sections: sections,backgroundColor: .clear,listInsets: .insets(bottom: listInsetBottom),- pageInsets: .insets(top: showClose ? R.Size.SheetGrabberTopInset : R.Size.ContentInsetTop))+ pageInsets: .insets(top: showClose ? R.Size.SheetGrabberTopInset : R.Size.ContentInsetTop(window: hostingWindow)))}private func masterCell(refreshSize: Bool = true) -> ASListPage.Cell {@@ -256,7 +256,7 @@ class ICloudSettingView: BaseView {switch row {case .master:if value.subActions?.extraValue == nil {- topViewController()?.present(PurchaseViewController(featuresType: .iCloud), animated: true)+ topViewController(in: hostingWindowScene)?.present(PurchaseViewController(featuresType: .iCloud), animated: true)return}guard let isOn = value.subActions?.extraValue as? Bool else { return }diff --git a/ManicEmu/ManicEmu/Sources/Business/Shaders/Views/ShaderLIstView.swift b/ManicEmu/ManicEmu/Sources/Business/Shaders/Views/ShaderLIstView.swiftindex 9646b31e..59b568a5 100644--- a/ManicEmu/ManicEmu/Sources/Business/Shaders/Views/ShaderLIstView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Shaders/Views/ShaderLIstView.swift@@ -311,7 +311,7 @@ class ShaderListView: BaseView {if showClose {make.top.equalToSuperview().offset(R.Size.SheetGrabberTopInset)} else {- make.top.equalToSuperview().offset(R.Size.ContentInsetTop)+ make.top.equalToSuperview().offset(R.Size.ContentInsetTop(window: hostingWindow))}make.leading.trailing.equalTo(safeAreaLayoutGuide)make.height.equalTo(R.Size.NavigationHeight)@@ -319,8 +319,6 @@ class ShaderListView: BaseView {addSubview(listPageView)- updateViewsContraits()-loadShader { [weak self] inself?.updateNavigation()}@@ -354,6 +352,11 @@ class ShaderListView: BaseView {fatalError("init(coder:) has not been implemented")}+ override func layoutSubviews() {+ super.layoutSubviews()+ updateViewsContraits()+ }+private func handleAction(_ action: ASListPage.Action) {if let toolValue = action.toolValue {if toolValue.isTapMain {@@ -786,7 +789,7 @@ class ShaderListView: BaseView {}private func getTop() -> (UIView, ASViewLayout, Bool) {- return (topView, .fixedHeight(UIDevice.isLandscape && showClose ? 116 : 318), true)+ return (topView, .fixedHeight(prefferedLayoutStyle == .landscape && showClose ? 116 : 318), true)}private func getCell(shader: Shader, isSelected: Bool) -> ASListPage.Cell {@@ -865,23 +868,23 @@ class ShaderListView: BaseView {title: R.string.localizable.cloudDriveBrowserDownload(),titleColor: R.Color.LabelPrimary.forceStyle(.dark),background: R.Color.Main),- layoutInsets: .insets(bottom: R.Size.ContentInsetBottom))+ layoutInsets: .insets(bottom: R.Size.ContentInsetBottom(window: hostingWindow)))case .imported:return .init(title: R.string.localizable.noShaders(),detail: R.string.localizable.importShader(),- layoutInsets: .insets(bottom: R.Size.ContentInsetBottom))+ layoutInsets: .insets(bottom: R.Size.ContentInsetBottom(window: hostingWindow)))case .custom:return .init(title: R.string.localizable.noShaders(),detail: R.string.localizable.customShaderDesc(),- layoutInsets: .insets(bottom: R.Size.ContentInsetBottom))+ layoutInsets: .insets(bottom: R.Size.ContentInsetBottom(window: hostingWindow)))}}private func getListPage() -> ASListPage {- let listInsetBottom = (UIDevice.isPad && !showClose) ? R.Size.ContentInsetBottom + R.Size.HomeTabBarSize.height + R.Size.ContentSpaceMedium : 0+ let listInsetBottom = (UIDevice.isPad && !showClose) ? R.Size.ContentInsetBottom(window: hostingWindow) + R.Size.HomeTabBarSize.height + R.Size.ContentSpaceMedium : 0return ASListPage(top: getTop(),sections: getSections(),@@ -966,6 +969,43 @@ class ShaderListView: BaseView {fileNames: [R.Strings.SlangShader, R.Strings.GLSLShader])})}++ private func updateViewsContraits() {+ previewView.removeFromSuperview()+ if prefferedLayoutStyle == .landscape, showClose {+ addSubview(previewView)+ previewView.snp.remakeConstraints { make in+ make.top.equalTo(navigationView.snp.bottom)+ make.leading.equalTo(navigationView)+ make.bottom.equalTo(safeAreaLayoutGuide)+ }+ listPageView.top = getTop()++ listPageView.snp.remakeConstraints { make in+ make.top.equalTo(navigationView.snp.bottom)+ make.leading.equalTo(previewView.snp.trailing)+ make.width.equalTo(previewView)+ make.trailing.equalTo(safeAreaLayoutGuide)+ make.bottom.equalToSuperview()+ }++ } else {+ topView.addSubview(previewView)+ previewView.snp.remakeConstraints { make in+ make.top.equalTo(segmentView.snp.bottom).offset(R.Size.ContentSpaceMedium)+ make.leading.trailing.equalToSuperview().inset(R.Size.ContentSpaceMedium)+ make.height.equalTo(182)+ }+ listPageView.top = getTop()++ listPageView.snp.remakeConstraints { make in+ make.top.equalTo(navigationView.snp.bottom)+ make.leading.equalTo(safeAreaLayoutGuide)+ make.trailing.equalTo(safeAreaLayoutGuide)+ make.bottom.equalToSuperview()+ }+ }+ }}extension ShaderListView: ShowableView {@@ -1009,47 +1049,3 @@ extension ShaderListView: ShowableView {return sheetData}}--extension ShaderListView: ViewTransition {- private func updateViewsContraits() {- previewView.removeFromSuperview()- if UIDevice.isLandscape, showClose {- addSubview(previewView)- previewView.snp.remakeConstraints { make in- make.top.equalTo(navigationView.snp.bottom)- make.leading.equalTo(navigationView)- make.bottom.equalTo(safeAreaLayoutGuide)- }- listPageView.top = getTop()-- listPageView.snp.remakeConstraints { make in- make.top.equalTo(navigationView.snp.bottom)- make.leading.equalTo(previewView.snp.trailing)- make.width.equalTo(previewView)- make.trailing.equalTo(safeAreaLayoutGuide)- make.bottom.equalToSuperview()- }-- } else {- topView.addSubview(previewView)- previewView.snp.remakeConstraints { make in- make.top.equalTo(segmentView.snp.bottom).offset(R.Size.ContentSpaceMedium)- make.leading.trailing.equalToSuperview().inset(R.Size.ContentSpaceMedium)- make.height.equalTo(182)- }- listPageView.top = getTop()-- listPageView.snp.remakeConstraints { make in- make.top.equalTo(navigationView.snp.bottom)- make.leading.equalTo(safeAreaLayoutGuide)- make.trailing.equalTo(safeAreaLayoutGuide)- make.bottom.equalToSuperview()- }- }- }-- func viewAlongsideTransition() {- guard showAsSheet else { return }- updateViewsContraits()- }-}diff --git a/ManicEmu/ManicEmu/Sources/Business/Shaders/Views/ShaderPreviewView.swift b/ManicEmu/ManicEmu/Sources/Business/Shaders/Views/ShaderPreviewView.swiftindex 14f89287..49019ae1 100644--- a/ManicEmu/ManicEmu/Sources/Business/Shaders/Views/ShaderPreviewView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Shaders/Views/ShaderPreviewView.swift@@ -18,7 +18,9 @@ class ShaderPreviewView: RoundAndBorderView {background: R.Color.BackgroundQuaternary))view.didTapButton = { [weak self] inguard let self else { return }- ImageFetcher.showCommonFetcher(sources: [.capture, .library, .file], completion: { [weak self] fetchImage, _ in+ ImageFetcher.showCommonFetcher(sources: [.capture, .library, .file],+ in: self.hostingWindowScene,+ completion: { [weak self] fetchImage, _ inguard let self, let fetchImage = fetchImage?.scaled(toSize: self.dimensions) else { return }self.image = fetchImage})diff --git a/ManicEmu/ManicEmu/Sources/Business/Skin/ViewControllers/FlexSkinSettingViewController.swift b/ManicEmu/ManicEmu/Sources/Business/Skin/ViewControllers/FlexSkinSettingViewController.swiftindex f3edc06e..22641bf9 100644--- a/ManicEmu/ManicEmu/Sources/Business/Skin/ViewControllers/FlexSkinSettingViewController.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Skin/ViewControllers/FlexSkinSettingViewController.swift@@ -175,7 +175,8 @@ class FlexSkinSettingViewController: BaseViewController {}if let controllerSkin = controlView.controllerSkin as? ControllerSkin,- let frames = controllerSkin.getFrames() {+ let hostingWindow,+ let frames = controllerSkin.getFrames(window: hostingWindow) {if let screens = controllerSkin.screens(for: traits) {for (index, screen) in screens.enumerated() {@@ -288,7 +289,8 @@ class FlexSkinSettingViewController: BaseViewController {for (index, screen) in screens.enumerated() {if let outputFrame = screen.outputFrame,let controllerSkin = controlView.controllerSkin as? ControllerSkin,- let frames = controllerSkin.getFrames() {+ let hostingWindow,+ let frames = controllerSkin.getFrames(window: hostingWindow) {let scaledFrame = outputFrame.applying(.init(scaleX: frames.skinFrame.width, y: frames.skinFrame.height))screensViews[index].frame = scaledFrameinitFrames.append(scaledFrame)@@ -629,7 +631,9 @@ extension FlexSkinSettingViewController {if let image = background?.image {sources += [.editImage(image)]}- ImageFetcher.showCommonFetcher(sources: sources, completion: { [weak self] image, source in+ ImageFetcher.showCommonFetcher(sources: sources,+ in: hostingWindowScene,+ completion: { [weak self] image, source inguard let self, let image else { return }if case .editImage = source {self.updateBackgroundImage(image)diff --git a/ManicEmu/ManicEmu/Sources/Business/Skin/ViewControllers/SkinPreviewViewController.swift b/ManicEmu/ManicEmu/Sources/Business/Skin/ViewControllers/SkinPreviewViewController.swiftindex fb6ed2ad..d4a4208b 100644--- a/ManicEmu/ManicEmu/Sources/Business/Skin/ViewControllers/SkinPreviewViewController.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Skin/ViewControllers/SkinPreviewViewController.swift@@ -26,7 +26,7 @@ class SkinPreviewViewController: BaseViewController {return view}()- init(skin: ControllerSkin, traits: ControllerSkin.Traits) {+ init(skin: ControllerSkin, traits: ControllerSkin.Traits, window: UIWindow) {self.skin = skinself.traits = traitssuper.init(fullScreen: true)@@ -36,17 +36,21 @@ class SkinPreviewViewController: BaseViewController {view.addSubview(controlView)var needToRotate = false- if traits.orientation == .portrait && (UIDevice.currentOrientation == .landscapeLeft || UIDevice.currentOrientation == .landscapeRight) {- needToRotate = true- } else if traits.orientation == .landscape && (UIDevice.currentOrientation == .portrait || UIDevice.currentOrientation == .portraitUpsideDown) {- needToRotate = true+ let isLandscapeLayoutIPad = UIDevice.isPad && ((UIDevice.isFullScreenIPad(window: window) && UIDevice.isLandscape) || window.size.IsRelativelyWideRectangle)++ if UIDevice.isPhone || UIDevice.isFullScreenIPad(window: window) {+ if traits.orientation == .portrait && UIDevice.isLandscape {+ needToRotate = true+ } else if traits.orientation == .landscape && UIDevice.isPortrait {+ needToRotate = true+ }}if needToRotate {controlView.snp.makeConstraints { make inmake.center.equalToSuperview()if let aspectRatio = skin.aspectRatio(for: traits) {- let frame = AVMakeRect(aspectRatio: aspectRatio, insideRect: CGRect(origin: .zero, size: CGSize(width: R.Size.WindowHeight, height: R.Size.WindowWidth)))+ let frame = AVMakeRect(aspectRatio: aspectRatio, insideRect: CGRect(origin: .zero, size: R.Size.ApplicationWindowSize.swapSide))make.size.equalTo(frame.size)}}@@ -55,7 +59,7 @@ class SkinPreviewViewController: BaseViewController {controlView.snp.makeConstraints { make inmake.center.equalToSuperview()if let aspectRatio = skin.aspectRatio(for: traits) {- let frame = AVMakeRect(aspectRatio: aspectRatio, insideRect: CGRect(origin: .zero, size: R.Size.WindowSize))+ let frame = AVMakeRect(aspectRatio: aspectRatio, insideRect: CGRect(origin: .zero, size: R.Size.ApplicationWindowSize))make.size.equalTo(frame.size)}}@@ -66,7 +70,7 @@ class SkinPreviewViewController: BaseViewController {self?.dismiss(animated: true)}closeButtonView.snp.makeConstraints { make in- make.top.equalToSuperview().offset(R.Size.SafeArea.top == 0 ? 20 : R.Size.SafeArea.top)+ make.top.equalToSuperview().offset(R.Size.ContentInsetTop(window: hostingWindow))make.trailing.equalToSuperview().offset(-R.Size.ContentSpaceLarge)}}diff --git a/ManicEmu/ManicEmu/Sources/Business/Skin/Views/PlayCasePromoView.swift b/ManicEmu/ManicEmu/Sources/Business/Skin/Views/PlayCasePromoView.swiftindex 34f1ef96..bad01aeb 100644--- a/ManicEmu/ManicEmu/Sources/Business/Skin/Views/PlayCasePromoView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Skin/Views/PlayCasePromoView.swift@@ -53,7 +53,7 @@ class PlayCasePromoView: BaseView {make.height.equalTo(R.Size.ItemHeightMedium)make.top.equalTo(detailLabel.snp.bottom).offset(R.Size.ItemHeightSmall)if !showDontShow {- make.bottom.equalToSuperview().inset(R.Size.ContentInsetBottom + R.Size.ContentSpaceSmall)+ make.bottom.equalToSuperview().inset(R.Size.ContentInsetBottom(window: hostingWindow) + R.Size.ContentSpaceSmall)}}@@ -74,7 +74,7 @@ class PlayCasePromoView: BaseView {dontshowAgain.snp.makeConstraints { make inmake.centerX.equalTo(button)make.top.equalTo(button.snp.bottom).offset(R.Size.ContentSpaceTiny)- make.bottom.equalToSuperview().inset(R.Size.ContentInsetBottom + R.Size.ContentSpaceSmall)+ make.bottom.equalToSuperview().inset(R.Size.ContentInsetBottom(window: hostingWindow) + R.Size.ContentSpaceSmall)}}diff --git a/ManicEmu/ManicEmu/Sources/Business/Skin/Views/SkinCollectionViewCell.swift b/ManicEmu/ManicEmu/Sources/Business/Skin/Views/SkinCollectionViewCell.swiftindex 30b038d0..dc75a7a6 100644--- a/ManicEmu/ManicEmu/Sources/Business/Skin/Views/SkinCollectionViewCell.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Skin/Views/SkinCollectionViewCell.swift@@ -184,9 +184,9 @@ class SkinCollectionViewCell: UICollectionViewCell {if needsSkinUpdate {let screenAspectRatio: CGFloatif traits.orientation == .portrait {- screenAspectRatio = R.Size.WindowSize.aspectRatio+ screenAspectRatio = R.Size.ApplicationWindowSize.aspectRatio} else {- screenAspectRatio = R.Size.WindowSize.height/R.Size.WindowSize.width+ screenAspectRatio = R.Size.ApplicationWindowSize.height/R.Size.ApplicationWindowSize.width}if let aspectRatio = controllerSkin?.aspectRatio(for: traits), abs(aspectRatio.aspectRatio - screenAspectRatio) > 0.1 {controllerView.snp.updateConstraints { make indiff --git a/ManicEmu/ManicEmu/Sources/Business/Skin/Views/SkinSettingsView.swift b/ManicEmu/ManicEmu/Sources/Business/Skin/Views/SkinSettingsView.swiftindex 0f7de304..362f109f 100644--- a/ManicEmu/ManicEmu/Sources/Business/Skin/Views/SkinSettingsView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Skin/Views/SkinSettingsView.swift@@ -53,7 +53,7 @@ class SkinSettingsView: BaseView {private var isPortraitSkinPage: Bool {segmentView.segment.index == 0}- private let defaultTraits: ControllerSkin.Traits = ControllerSkin.Traits.defaults(for: UIWindow.applicationWindow ?? UIWindow(frame: .init(origin: .zero, size: R.Size.WindowSize)))+ private let defaultTraits: ControllerSkin.Traits = ControllerSkin.Traits.defaults(for: UIWindow.applicationWindow ?? UIWindow(frame: .init(origin: .zero, size: R.Size.ApplicationWindowSize)))private var currentTraits: ControllerSkin.Traits {isPortraitSkinPage ? portraitTraits : landscapeTraits}@@ -107,7 +107,7 @@ class SkinSettingsView: BaseView {private var skinRenderGeneration = 0private var collectionViewContentInsetBottom: CGFloat {- R.Size.ContentInsetBottom + ((UIDevice.isPad && !showClose) ? R.Size.HomeTabBarSize.height + R.Size.ContentSpaceMedium : 0)+ R.Size.ContentInsetBottom(window: hostingWindow) + ((UIDevice.isPad && !showClose) ? R.Size.HomeTabBarSize.height + R.Size.ContentSpaceMedium : 0)}private lazy var navigation: ASListPage.Navigation = {@@ -376,7 +376,7 @@ class SkinSettingsView: BaseView {self?.collectionView.reloadData()}}- topViewController()?.present(vc, animated: true)+ topViewController(in: hostingWindowScene)?.present(vc, animated: true)} else {//delete@@ -444,7 +444,7 @@ class SkinSettingsView: BaseView {if showClose {make.top.equalToSuperview().offset(R.Size.SheetGrabberTopInset)} else {- make.top.equalToSuperview().offset(R.Size.ContentInsetTop)+ make.top.equalToSuperview().offset(R.Size.ContentInsetTop(window: hostingWindow))}make.leading.trailing.equalToSuperview()make.height.equalTo(R.Size.NavigationHeight)@@ -470,7 +470,7 @@ class SkinSettingsView: BaseView {make.height.equalTo(R.Size.ButtonLarge)}- if UIDevice.isLandscape {+ if proHUDLayoutStyle() == .landscape {segmentView.segment.index = 1}@@ -491,16 +491,22 @@ class SkinSettingsView: BaseView {private func createLayout() -> UICollectionViewLayout {let layout = UICollectionViewCompositionalLayout { [weak self] sectionIndex, env in- guard let self = self else { return nil }+ guard let self else { return nil }var column: CGFloat = self.isPortraitSkinPage ? 2.0 : 1.0- if UIDevice.isPad, UIDevice.isLandscape {+ if UIDevice.isPad, self.prefferedLayoutStyle == .landscape {column = self.isPortraitSkinPage ? 3.0 : 2.0}let item = NSCollectionLayoutItem(layoutSize: NSCollectionLayoutSize(widthDimension: .fractionalWidth(1/column), heightDimension: .fractionalHeight(1)))- let screenRation = R.Size.WindowSize.maxDimension/R.Size.WindowSize.minDimension+ let screenRation: CGFloat+ if let screen = self.hostingWindow?.screen {+ screenRation = screen.bounds.size.maxDimension/screen.bounds.size.minDimension+ } else {+ screenRation = R.Size.ApplicationWindowSize.maxDimension/R.Size.ApplicationWindowSize.minDimension+ }+let itemWidth = (env.container.contentSize.width - R.Size.ContentSpaceMedium*4 - ((column-1)*R.Size.ContentSpaceMedium))/columnlet itemHeight = self.isPortraitSkinPage ? itemWidth*screenRation : itemWidth/screenRation@@ -769,10 +775,12 @@ extension SkinSettingsView: UICollectionViewDataSource {isUsing: isUsing,isEditable: skin.isEditable,renderGeneration: skinRenderGeneration)- cell.onPreview = {- if let controllerSkin = skin.controllerSkin {- topViewController()?.present(SkinPreviewViewController(skin: controllerSkin,- traits: traits),+ cell.onPreview = { [weak self] in+ guard let self else { return }+ if let controllerSkin = skin.controllerSkin, let w = self.hostingWindow {+ topViewController(in: self.hostingWindowScene)?.present(SkinPreviewViewController(skin: controllerSkin,+ traits: traits,+ window: w),animated: true)}}@@ -856,8 +864,9 @@ extension SkinSettingsView: UICollectionViewDelegate {UIView.makeAlert(title: R.string.localizable.skinAddTitle(), detail: R.string.localizable.newSkinDesc(), cancelTitle: R.string.localizable.visitSite("DELTASTYLES"), confirmTitle: R.string.localizable.openFile(), cancelAction: { [weak self] inguard let self else { return }ASWebView.show(url: R.URLs.DeltaStyles(gameType: self.gameType))- }, confirmAction: {- FilesImporter.shared.presentImportController(supportedTypes: UTType.skinTypes)+ }, confirmAction: { [weak self] in+ guard let self else { return }+ FilesImporter.shared.presentImportController(supportedTypes: UTType.skinTypes, in: self.hostingWindowScene)})} else {if let currentUsingIndex, currentUsingIndex == indexPath.row {diff --git a/ManicEmu/ManicEmu/Sources/Business/TriggerPro/ViewControllers/TriggerProPreviewController.swift b/ManicEmu/ManicEmu/Sources/Business/TriggerPro/ViewControllers/TriggerProPreviewController.swiftindex a30cf93c..a149a385 100644--- a/ManicEmu/ManicEmu/Sources/Business/TriggerPro/ViewControllers/TriggerProPreviewController.swift+++ b/ManicEmu/ManicEmu/Sources/Business/TriggerPro/ViewControllers/TriggerProPreviewController.swift@@ -180,7 +180,11 @@ class TriggerProPreviewController: BaseViewController {}}- init(gameType: GameType, trigger: Trigger? = nil, preferredSkinID: String? = nil, hideControls: Bool = false) {+ init(gameType: GameType,+ trigger: Trigger? = nil,+ preferredSkinID: String? = nil,+ hideControls: Bool = false,+ window: UIWindow) {let realm = Database.realmself.defaultSkin = ControllerSkin.standardControllerSkin(for: gameType)!if let preferredSkinID,@@ -190,7 +194,7 @@ class TriggerProPreviewController: BaseViewController {} else {self.skin = self.defaultSkin}- self.traits = ControllerSkin.Traits.defaults(for: UIWindow.applicationWindow ?? UIWindow(frame: .init(origin: .zero, size: R.Size.WindowSize)))+ self.traits = ControllerSkin.Traits.defaults(for: UIWindow.applicationWindow ?? UIWindow(frame: .init(origin: .zero, size: R.Size.ApplicationWindowSize)))if let trigger {//将数据库实例转换为临时实例 为了更方便的修改 保存的时候统一修改数据库self.trigger = trigger.copyTrigger()@@ -218,7 +222,7 @@ class TriggerProPreviewController: BaseViewController {controlView.snp.makeConstraints { make inmake.center.equalToSuperview()if let aspectRatio = skin.aspectRatio(for: traits) {- let frame = AVMakeRect(aspectRatio: aspectRatio, insideRect: CGRect(origin: .zero, size: CGSize(width: R.Size.WindowHeight, height: R.Size.WindowWidth)))+ let frame = AVMakeRect(aspectRatio: aspectRatio, insideRect: CGRect(origin: .zero, size: R.Size.ApplicationWindowSize.swapSide))make.size.equalTo(frame.size)}}@@ -227,7 +231,7 @@ class TriggerProPreviewController: BaseViewController {controlView.snp.makeConstraints { make inmake.center.equalToSuperview()if let aspectRatio = skin.aspectRatio(for: traits) {- let frame = AVMakeRect(aspectRatio: aspectRatio, insideRect: CGRect(origin: .zero, size: R.Size.WindowSize))+ let frame = AVMakeRect(aspectRatio: aspectRatio, insideRect: CGRect(origin: .zero, size: R.Size.ApplicationWindowSize))make.size.equalTo(frame.size)}}@@ -236,11 +240,11 @@ class TriggerProPreviewController: BaseViewController {view.addSubview(navigationView)navigationView.snp.makeConstraints { make inmake.leading.trailing.equalTo(view.safeAreaLayoutGuide)- make.top.equalToSuperview().offset(R.Size.ContentInsetTop)+ make.top.equalToSuperview().offset(R.Size.ContentInsetTop(window: hostingWindow))make.height.equalTo(R.Size.NavigationHeight)}- if let skinFrames = skin.getFrames() {+ if let skinFrames = skin.getFrames(window: window) {controlView.addSubview(gameViewBackgroundView)gameViewBackgroundView.snp.makeConstraints { make inmake.leading.equalTo(skinFrames.mainGameViewFrame.minX)diff --git a/ManicEmu/ManicEmu/Sources/Business/TriggerPro/Views/AddTriggerButtonStyleView.swift b/ManicEmu/ManicEmu/Sources/Business/TriggerPro/Views/AddTriggerButtonStyleView.swiftindex dfe6946b..5c2c4e75 100644--- a/ManicEmu/ManicEmu/Sources/Business/TriggerPro/Views/AddTriggerButtonStyleView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/TriggerPro/Views/AddTriggerButtonStyleView.swift@@ -73,7 +73,9 @@ class AddTriggerButtonStyleView: BaseView {guard let self = self else { return }if self.style == .custom {//上传照片- ImageFetcher.showCommonFetcher(sources: [.capture, .library, .file], completion: { [weak self] image, _ in+ ImageFetcher.showCommonFetcher(sources: [.capture, .library, .file],+ in: self.hostingWindowScene,+ completion: { [weak self] image, _ inif let image = image?.scaled(toSize: self?.buttonSize ?? TriggerItem.Style.custom.defaultSize) {self?.triggerButton.image = imageself?.didImageChange?(image)diff --git a/ManicEmu/ManicEmu/Sources/Business/TriggerPro/Views/AddTriggerMappingListView.swift b/ManicEmu/ManicEmu/Sources/Business/TriggerPro/Views/AddTriggerMappingListView.swiftindex 299cdd93..d9b8be92 100644--- a/ManicEmu/ManicEmu/Sources/Business/TriggerPro/Views/AddTriggerMappingListView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/TriggerPro/Views/AddTriggerMappingListView.swift@@ -387,7 +387,7 @@ class TriggerProMappingListView: BaseView {let isLastSection = sectionIndex == (self.inputs.count - 1)- section.contentInsets = NSDirectionalEdgeInsets(top: sectionIndex == 0 ? R.Size.ContentSpaceSmall : R.Size.ContentSpaceHuge, leading: 0, bottom: R.Size.ContentSpaceHuge + (isLastSection ? R.Size.SafeArea.bottom : 0), trailing: 0)+ section.contentInsets = NSDirectionalEdgeInsets(top: sectionIndex == 0 ? R.Size.ContentSpaceSmall : R.Size.ContentSpaceHuge, leading: 0, bottom: R.Size.ContentSpaceHuge + (isLastSection ? self.safeAreaInsets.bottom : 0), trailing: 0)//headerif sectionIndex != 0 {diff --git a/ManicEmu/ManicEmu/Sources/Business/TriggerPro/Views/TriggerProManageView.swift b/ManicEmu/ManicEmu/Sources/Business/TriggerPro/Views/TriggerProManageView.swiftindex 4d07d299..fdf3dd7b 100644--- a/ManicEmu/ManicEmu/Sources/Business/TriggerPro/Views/TriggerProManageView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/TriggerPro/Views/TriggerProManageView.swift@@ -125,6 +125,7 @@ class TriggerProManageView: BaseView {}private func handleAction(_ action: ASListPage.Action) {+ guard let hostingWindow else { return }if let navigationValue = action.navigationValue {//navigation actionif navigationValue.isTapClose {@@ -180,10 +181,11 @@ class TriggerProManageView: BaseView {} else if index == 1 {//edit- topViewController()?.present(TriggerProPreviewController(gameType: trigger.gameType,+ topViewController(in: hostingWindowScene)?.present(TriggerProPreviewController(gameType: trigger.gameType,trigger: trigger,preferredSkinID: PlayViewController.currentSkinID,- hideControls: PlayViewController.isHideControls),+ hideControls: PlayViewController.isHideControls,+ window: hostingWindow),animated: true)} else if index == 2 {//set up for more games@@ -297,16 +299,17 @@ class TriggerProManageView: BaseView {selectedItems.insert(indexPath)}} else {- topViewController()?.present(TriggerProPreviewController(gameType: trigger.gameType,- trigger: trigger,- preferredSkinID: PlayViewController.currentSkinID,- hideControls: PlayViewController.isHideControls),- animated: true)+ topViewController(in: hostingWindowScene)?.present(TriggerProPreviewController(gameType: trigger.gameType,+ trigger: trigger,+ preferredSkinID: PlayViewController.currentSkinID,+ hideControls: PlayViewController.isHideControls,+ window: hostingWindow),+ animated: true)}} else if action.isBottom {//add triggerif !PurchaseManager.isMember, allTriggers.count >= R.Numbers.NonMemberTriggerProCount {- topViewController()?.present(PurchaseViewController(), animated: true)+ topViewController(in: hostingWindowScene)?.present(PurchaseViewController(), animated: true)return}@@ -314,12 +317,14 @@ class TriggerProManageView: BaseView {ChevronSheetView.show(icon: .symbolImage(R.image.category_iconSymbols()),title: R.string.localizable.platformSelectionTitle(),stringOptions: allGameTypes.map({ $0.localizedShortName }),- completion: { index in+ completion: { [weak self] index in+ guard let self else { return }guard let index else { return }- topViewController()?.present(TriggerProPreviewController(gameType: allGameTypes[index],- preferredSkinID: PlayViewController.currentSkinID,- hideControls: PlayViewController.isHideControls),- animated: true)+ topViewController(in: self.hostingWindowScene)?.present(TriggerProPreviewController(gameType: allGameTypes[index],+ preferredSkinID: PlayViewController.currentSkinID,+ hideControls: PlayViewController.isHideControls,+ window: hostingWindow),+ animated: true)})} else if let indexPath = action.longPressValue {guard !isEditMode else { return }@@ -364,7 +369,7 @@ class TriggerProManageView: BaseView {}private func getListPage() -> ASListPage {- let listInsetBottom = (UIDevice.isPad && !showClose) ? R.Size.ContentInsetBottom + R.Size.HomeTabBarSize.height + R.Size.ContentSpaceMedium : 0+ let listInsetBottom = (UIDevice.isPad && !showClose) ? R.Size.ContentInsetBottom(window: hostingWindow) + R.Size.HomeTabBarSize.height + R.Size.ContentSpaceMedium : 0return ASListPage(navigation: getNavigation(),sections: getSections(),@@ -375,7 +380,7 @@ class TriggerProManageView: BaseView {blankSlate: .init(),backgroundColor: .clear,listInsets: .insets(bottom: listInsetBottom),- pageInsets: .insets(top: showClose ? R.Size.SheetGrabberTopInset : R.Size.ContentInsetTop),+ pageInsets: .insets(top: showClose ? R.Size.SheetGrabberTopInset : R.Size.ContentInsetTop(window: hostingWindow)),enableLongPress: true)}diff --git a/ManicEmu/ManicEmu/Sources/Tools/Extensions/CGSizeExtenstions.swift b/ManicEmu/ManicEmu/Sources/Tools/Extensions/CGSizeExtenstions.swiftindex a4ad8099..58e58a51 100644--- a/ManicEmu/ManicEmu/Sources/Tools/Extensions/CGSizeExtenstions.swift+++ b/ManicEmu/ManicEmu/Sources/Tools/Extensions/CGSizeExtenstions.swift@@ -23,4 +23,9 @@ extension CGSize {var swapSide: CGSize {return CGSize(width: height, height: width)}++ var IsRelativelyWideRectangle: Bool {+ guard self != .zero else { return false }+ return width/height > 1.333+ }}diff --git a/ManicEmu/ManicEmu/Sources/Tools/Extensions/ControllerSkinExtensions.swift b/ManicEmu/ManicEmu/Sources/Tools/Extensions/ControllerSkinExtensions.swiftindex 1a8570b9..41382370 100644--- a/ManicEmu/ManicEmu/Sources/Tools/Extensions/ControllerSkinExtensions.swift+++ b/ManicEmu/ManicEmu/Sources/Tools/Extensions/ControllerSkinExtensions.swift@@ -11,9 +11,10 @@import AVFoundationextension ControllerSkin {- func getFrames(traits: ControllerSkin.Traits = ControllerSkin.Traits.defaults(for: UIWindow.applicationWindow ?? UIWindow(frame: .init(origin: .zero, size: R.Size.WindowSize))), scale: CGFloat = 1) -> (skinFrame: CGRect, mainGameViewFrame: CGRect, touchGameViewFrame: CGRect?)? {+ func getFrames(window: UIWindow, scale: CGFloat = 1) -> (skinFrame: CGRect, mainGameViewFrame: CGRect, touchGameViewFrame: CGRect?)? {+ let traits: ControllerSkin.Traits = ControllerSkin.Traits.defaults(for: window)if let screens = self.screens(for: traits), let aspectRatio = self.aspectRatio(for: traits) {- var skinFrame = AVMakeRect(aspectRatio: aspectRatio, insideRect: UIScreen.main.bounds).rounded()+ var skinFrame = AVMakeRect(aspectRatio: aspectRatio, insideRect: window.bounds).rounded()if scale != 1 {skinFrame = skinFrame.applying(CGAffineTransform(scaleX: scale, y: scale))}diff --git a/ManicEmu/ManicEmu/Sources/Tools/Extensions/NumbersExtensions.swift b/ManicEmu/ManicEmu/Sources/Tools/Extensions/NumbersExtensions.swiftindex e4f5a114..7bab0cfd 100644--- a/ManicEmu/ManicEmu/Sources/Tools/Extensions/NumbersExtensions.swift+++ b/ManicEmu/ManicEmu/Sources/Tools/Extensions/NumbersExtensions.swift@@ -61,7 +61,7 @@ extension DecimalConvertible {(roundedDecimal(scale: scale) as NSDecimalNumber).doubleValue}- func roundedCGFloat(scale: Int = 1) -> Float {+ func roundedFloat(scale: Int = 1) -> Float {roundedDouble(scale: scale).float}@@ -96,3 +96,9 @@ extension Decimal {(self as NSDecimalNumber).floatValue}}++extension BinaryFloatingPoint {+ func rounded1(rule: FloatingPointRoundingRule = .toNearestOrAwayFromZero) -> Self {+ return rounded(numberOfDecimalPlaces: 1, rule: rule)+ }+}diff --git a/ManicEmu/ManicEmu/Sources/Tools/Extensions/ProHUDExtensions.swift b/ManicEmu/ManicEmu/Sources/Tools/Extensions/ProHUDExtensions.swiftnew file mode 100644index 00000000..b7a38e15--- /dev/null+++ b/ManicEmu/ManicEmu/Sources/Tools/Extensions/ProHUDExtensions.swift@@ -0,0 +1,22 @@+//+// ProHUDExtensions.swift+// ManicEmu+//+// Created by Daiuno on 2026/10/15.+// Copyright © 2026 Manic EMU. All rights reserved.+//++import ProHUD++func proHUDWindow() -> UIWindow? {+ AppContext.appWindow ?? UIWindow.applicationWindow+}++func proHUDLayoutStyle() -> UIView.LayoutStyle {+ if let w = proHUDWindow() {+ return w.size.IsRelativelyWideRectangle ? .landscape : .portrait+ }+ return UIDevice.isLandscape ? .landscape : .portrait+}++diff --git a/ManicEmu/ManicEmu/Sources/Tools/Extensions/UIDeviceExtensions.swift b/ManicEmu/ManicEmu/Sources/Tools/Extensions/UIDeviceExtensions.swiftindex 8cb17ea1..0c0a16df 100644--- a/ManicEmu/ManicEmu/Sources/Tools/Extensions/UIDeviceExtensions.swift+++ b/ManicEmu/ManicEmu/Sources/Tools/Extensions/UIDeviceExtensions.swift@@ -62,39 +62,6 @@ extension UIDevice {CHHapticEngine.capabilitiesForHardware().supportsHaptics}- enum LayoutStyle: String {- case iPadFullscreen = "iPad Full Screen"- case iPadHalfScreen = "iPad 1/2 Screen"- case iPadTwoThirdScreeen = "iPad 2/3 Screen"- case iPadOneThirdScreen = "iPad 1/3 Screen"- case iPhoneFullScreen = "iPhone"- }-- static var layoutStyle: LayoutStyle {- if UIDevice.current.userInterfaceIdiom == .phone {- return .iPhoneFullScreen- }- let screenSize = UIScreen.main.bounds.size- let appSize = R.Size.WindowSize- let screenWidth = screenSize.width- let appWidth = appSize.width-- if screenSize == appSize {- return .iPadFullscreen- }- let persent = CGFloat(appWidth / screenWidth) * 100.0- if persent <= 55.0 && persent >= 45.0 {- // 半分屏- return .iPadHalfScreen- } else if persent > 55.0 {- // 2/3- return .iPadTwoThirdScreeen- } else {- // 1/3- return .iPadOneThirdScreen- }- }-static var isLandscape: Bool {UIDevice.currentOrientation == .landscapeLeft || UIDevice.currentOrientation == .landscapeRight}@@ -104,8 +71,19 @@ extension UIDevice {}static var isPadMini: Bool {- if UIDevice.isPad, R.Size.WindowSize.minDimension <= 744 {- return true+ if UIDevice.isPad {+ switch Device.version(detectSimulator: true) {+ case .iPadMini,+ .iPadMini2,+ .iPadMini3,+ .iPadMini4,+ .iPadMini5,+ .iPadMini6,+ .iPadMini7:+ return true+ default:+ return false+ }}return false}@@ -118,20 +96,48 @@ extension UIDevice {return isPhone && Device.size().rawValue >= Size.screen6_3Inch.rawValue}+ static func isFullScreenIPad(window: UIWindow) -> Bool {+ guard isPad else { return false }+ return window.bounds.equalTo(window.screen.bounds)+ }++ static func isWindowAppIPad(window: UIWindow) -> Bool {+ guard isPad else { return false }+ return !window.bounds.equalTo(window.screen.bounds)+ }+static var currentOrientation: UIInterfaceOrientation {UIWindow.applicationWindow?.windowScene?.interfaceOrientation ?? .portrait}static var hasNotch: Bool {- let insets = R.Size.SafeArea- let orientation = UIDevice.currentOrientation- if orientation == .landscapeRight {- return insets.left > 20- } else if orientation == .landscapeLeft {- return insets.right > 20- } else if orientation == .portraitUpsideDown {- return insets.bottom > 20+ switch Device.version(detectSimulator: true) {+ case .iPhoneX,+ .iPhoneXS,+ .iPhoneXS_Max,+ .iPhoneXR,+ .iPhone11,+ .iPhone11Pro,+ .iPhone11Pro_Max,+ .iPhone12Mini,+ .iPhone12,+ .iPhone12Pro,+ .iPhone12Pro_Max,+ .iPhone13Mini,+ .iPhone13,+ .iPhone13Pro,+ .iPhone13Pro_Max,+ .iPhone14,+ .iPhone14Plus,+ .iPhone16e,+ .iPhone17e:+ return true+ default:+ return false}- return insets.top > 20+ }++ static var hasDynamicIsland: Bool {+ Device.hasDynamicIsland}private static var mtlDevice: MTLDevice? = MTLCreateSystemDefaultDevice()@@ -153,23 +159,15 @@ extension UIDevice {}static var isPhone: Bool {- if Device.isPhone() || Device.isPod() {+ if Device.isPhone(detectSimulator: true) || Device.isPod(detectSimulator: true) {return true- } else if Device.isSimulator() {- if R.Size.WindowSize.minDimension < 744 { //ipad mini 8.3寸 最小宽度是744- return true- }}return false}static var isPad: Bool {- if Device.isPad() {+ if Device.isPad(detectSimulator: true) {return true- } else if Device.isSimulator() {- if R.Size.WindowSize.minDimension >= 744 { //ipad mini 8.3寸 最小宽度是744- return true- }}return false}@@ -181,7 +179,7 @@ extension UIDevice {}static var isDarkMode: Bool {- ApplicationSceneDelegate.applicationWindow?.traitCollection.userInterfaceStyle == .dark+ UIWindow.applicationWindow?.traitCollection.userInterfaceStyle == .dark}static var isIOS15: Bool {@@ -430,7 +428,7 @@ enum OrientationLockPin {}private static func notifyOrientationControllers() {- var vc = ApplicationSceneDelegate.applicationWindow?.rootViewController+ var vc = UIWindow.applicationWindow?.rootViewControllerwhile let current = vc {if #available(iOS 16.0, *) {current.setNeedsUpdateOfSupportedInterfaceOrientations()@@ -454,7 +452,7 @@ enum OrientationLockPin {private static func currentInterfaceOrientation() -> UIInterfaceOrientation {ApplicationSceneDelegate.applicationScene?.interfaceOrientation- ?? ApplicationSceneDelegate.applicationWindow?.windowScene?.interfaceOrientation+ ?? UIWindow.applicationWindow?.windowScene?.interfaceOrientation?? UIDevice.currentOrientation}diff --git a/ManicEmu/ManicEmu/Sources/Tools/Extensions/UIViewControllerExtensions.swift b/ManicEmu/ManicEmu/Sources/Tools/Extensions/UIViewControllerExtensions.swiftnew file mode 100644index 00000000..47ca1425--- /dev/null+++ b/ManicEmu/ManicEmu/Sources/Tools/Extensions/UIViewControllerExtensions.swift@@ -0,0 +1,17 @@+//+// UIViewControllerExtensions.swift+// ManicEmu+//+// Created by Daiuno on 2026/10/1.+// Copyright © 2026 Manic EMU. All rights reserved.+//++extension UIViewController {+ var hostingWindow: UIWindow? {+ view.window+ }++ var hostingWindowScene: UIWindowScene? {+ hostingWindow?.windowScene+ }+}diff --git a/ManicEmu/ManicEmu/Sources/Tools/Extensions/UIViewExtensions.swift b/ManicEmu/ManicEmu/Sources/Tools/Extensions/UIViewExtensions.swiftindex d914f208..d6f650f5 100644--- a/ManicEmu/ManicEmu/Sources/Tools/Extensions/UIViewExtensions.swift+++ b/ManicEmu/ManicEmu/Sources/Tools/Extensions/UIViewExtensions.swift@@ -118,7 +118,7 @@ extension UIView {toast.onViewDidDisappear { _ inhideCompletion?()}- let maxWidth = R.Size.WindowWidth - 2*R.Size.ContentSpaceLarge+ let maxWidth = (AppContext.appWindow?.size ?? R.Size.ApplicationWindowSize).width - 2*R.Size.ContentSpaceLargelet insets = UIEdgeInsets(horizontal: R.Size.ContentSpaceHuge*2, vertical: 14*2)toast.config.cardEdgeInsets = insetslet font = R.Font.Headline(emphasis: true)@@ -366,7 +366,7 @@ extension UIView {func asImage() -> UIImage {let format = UIGraphicsImageRendererFormat.default()- format.scale = UIScreen.main.scale+ format.scale = traitCollection.displayScaleformat.opaque = isOpaquelet renderer = UIGraphicsImageRenderer(size: bounds.size, format: format)@@ -378,4 +378,38 @@ extension UIView {var windowSafeArea: UIEdgeInsets {window?.safeAreaInsets ?? .zero}++ var hostingWindow: UIWindow? {+ window+ }++ var hostingWindowScene: UIWindowScene? {+ hostingWindow?.windowScene+ }++ enum LayoutStyle {+ case landscape+ case portrait+ }++ var prefferedLayoutStyle: LayoutStyle {+ let w = hostingWindow ?? ApplicationSceneDelegate.applicationWindow+ if let w, w.size != .zero {+ if w.size.IsRelativelyWideRectangle {+ return .landscape+ } else {+ return .portrait+ }+ } else {+ return UIDevice.isLandscape ? .landscape : .portrait+ }+ }++ var isWindowHasEnoughSpaceforIpadMultiColumnLayout: Bool {+ guard UIDevice.isPad else { return false }+ if let w = hostingWindow {+ return w.width > 600+ }+ return false+ }}diff --git a/ManicEmu/ManicEmu/Sources/Tools/Extensions/UIWindowExtensions.swift b/ManicEmu/ManicEmu/Sources/Tools/Extensions/UIWindowExtensions.swiftindex b8feadd5..2b05ca78 100644--- a/ManicEmu/ManicEmu/Sources/Tools/Extensions/UIWindowExtensions.swift+++ b/ManicEmu/ManicEmu/Sources/Tools/Extensions/UIWindowExtensions.swift@@ -9,6 +9,7 @@import Foundationimport UIKit+import ProHUDextension UIWindow {static var applicationWindow: UIWindow? {@@ -21,8 +22,11 @@ extension UIWindow {#endif}- static var topWindow: UIWindow? {- if let window = ApplicationSceneDelegate.applicationScene?.windows.last(where: { w in+ /// Content window in `scene`, skipping alerts and keeping an elevated ProHUD sheet when one is visible.+ /// Pass nil to resolve the main application scene. A scene that was passed in is never replaced by another scene's window.+ static func topWindow(in scene: UIWindowScene?) -> UIWindow? {+ let resolvedScene = scene ?? ApplicationSceneDelegate.applicationScene+ if let window = resolvedScene?.windows.last(where: { w inif w.isHidden {return false}@@ -47,7 +51,10 @@ extension UIWindow {}) {return window}- return applicationWindow+ if scene == nil {+ return applicationWindow+ }+ return nil}#if os(iOS)diff --git a/ManicEmu/ManicEmu/Sources/Tools/FocusKit/FocusShortcutsTipsView.swift b/ManicEmu/ManicEmu/Sources/Tools/FocusKit/FocusShortcutsTipsView.swiftindex 146b811a..2060aee5 100644--- a/ManicEmu/ManicEmu/Sources/Tools/FocusKit/FocusShortcutsTipsView.swift+++ b/ManicEmu/ManicEmu/Sources/Tools/FocusKit/FocusShortcutsTipsView.swift@@ -122,7 +122,7 @@ final class FocusShortcutsTipsView: BaseView, ViewTransition {}private func present(source: Source) {- guard let window = UIWindow.topWindow else { return }+ guard let window = UIWindow.topWindow(in: FocusSystem.shared.currentContext?.rootView?.hostingWindowScene) else { return }self.source = sourcereloadItems()if superview !== window {diff --git a/ManicEmu/ManicEmu/Sources/Tools/JIT/StikJITManager.swift b/ManicEmu/ManicEmu/Sources/Tools/JIT/StikJITManager.swiftindex 433c7e91..f2314558 100644--- a/ManicEmu/ManicEmu/Sources/Tools/JIT/StikJITManager.swift+++ b/ManicEmu/ManicEmu/Sources/Tools/JIT/StikJITManager.swift@@ -125,7 +125,8 @@ final class StikJITManager: NSObject {}}- func presentPairingFilePicker(completion: @escaping (Bool, String?) -> Void) {+ func presentPairingFilePicker(in scene: UIWindowScene?,+ completion: @escaping (Bool, String?) -> Void) {let types: [UTType] = [.propertyList, UTType(filenameExtension: "plist")].compactMap { $0 }let picker = UIDocumentPickerViewController(forOpeningContentTypes: types, asCopy: true)picker.delegate = self@@ -148,7 +149,7 @@ final class StikJITManager: NSObject {completion(false, error.localizedDescription)}}- topViewController()?.present(picker, animated: true)+ topViewController(in: scene)?.present(picker, animated: true)}func invalidateReadiness() {diff --git a/ManicEmu/ManicEmu/Sources/Tools/Others/CloudDriveConnetor.swift b/ManicEmu/ManicEmu/Sources/Tools/Others/CloudDriveConnetor.swiftindex a31689d3..b8605ab0 100644--- a/ManicEmu/ManicEmu/Sources/Tools/Others/CloudDriveConnetor.swift+++ b/ManicEmu/ManicEmu/Sources/Tools/Others/CloudDriveConnetor.swift@@ -37,11 +37,11 @@ class CloudDriveConnetor {return connector}- func connect(service: ImportService) {+ func connect(service: ImportService, in scene: UIWindowScene?) {Log.debug("开始连接云服务:\(service.title)")currentConnector = genConnector(for: service.type)guard let connector = currentConnector else { return }- guard let topViewController = topViewController() else { return }+ guard let topViewController = topViewController(in: scene) else { return }connector.connect(viewController: topViewController) { [weak self] connectResult inswitch connectResult {case .success(let connectSuccess):diff --git a/ManicEmu/ManicEmu/Sources/Tools/Others/DownloadManager.swift b/ManicEmu/ManicEmu/Sources/Tools/Others/DownloadManager.swiftindex 75941416..d57fecf2 100644--- a/ManicEmu/ManicEmu/Sources/Tools/Others/DownloadManager.swift+++ b/ManicEmu/ManicEmu/Sources/Tools/Others/DownloadManager.swift@@ -91,7 +91,7 @@ class DownloadManager {}if succeededTasks.count > 0 {- FilesImporter.importFiles(urls: succeededTasks.map({ URL(fileURLWithPath: $0.filePath) })) {+ FilesImporter.importFiles(urls: succeededTasks.map({ URL(fileURLWithPath: $0.filePath) }), in: nil) {succeededTasks.forEach { manager.remove($0.url) }}}diff --git a/ManicEmu/ManicEmu/Sources/Tools/Others/EmulatorInteractionKit.swift b/ManicEmu/ManicEmu/Sources/Tools/Others/EmulatorInteractionKit.swiftindex 353c94f5..e6a661c4 100644--- a/ManicEmu/ManicEmu/Sources/Tools/Others/EmulatorInteractionKit.swift+++ b/ManicEmu/ManicEmu/Sources/Tools/Others/EmulatorInteractionKit.swift@@ -162,7 +162,7 @@ struct EmulatorInteractionKit {static func processGames(type: EmulatorType, callbackUrl: URL) {var delay: Double- if let _ = ApplicationSceneDelegate.applicationWindow {+ if let _ = UIWindow.applicationWindow {delay = 0.0} else {delay = 3.0diff --git a/ManicEmu/ManicEmu/Sources/Tools/Others/FilesImporter.swift b/ManicEmu/ManicEmu/Sources/Tools/Others/FilesImporter.swiftindex 91d9e865..81932cac 100644--- a/ManicEmu/ManicEmu/Sources/Tools/Others/FilesImporter.swift+++ b/ManicEmu/ManicEmu/Sources/Tools/Others/FilesImporter.swift@@ -22,21 +22,28 @@ class FilesImporter: NSObject {private override init() {}private var manualHandle: (([URL])->Void)? = nilprivate var cancelHandle: (() -> Void)? = nil+ private weak var scene: UIWindowScene? = nilfunc presentImportController(supportedTypes: [UTType] = UTType.allTypes,allowsMultipleSelection: Bool = true,manualHandle: (([URL])->Void)? = nil,cancelHandle: (() -> Void)? = nil,- appControllerPresent: Bool = false) {+ appControllerPresent: Bool = false,+ in scene: UIWindowScene?) {let documentPickerViewController = UIDocumentPickerViewController(forOpeningContentTypes: supportedTypes, asCopy: true)documentPickerViewController.delegate = selfdocumentPickerViewController.overrideUserInterfaceStyle = UIDevice.isDarkMode ? .dark : .lightdocumentPickerViewController.allowsMultipleSelection = allowsMultipleSelectiondocumentPickerViewController.modalPresentationStyle = .formSheetdocumentPickerViewController.sheetPresentationController?.preferredCornerRadius = R.Size.CornerRadiusLarge- topViewController(appController: appControllerPresent)?.present(documentPickerViewController, animated: true)+ if appControllerPresent {+ topApplicationViewController()?.present(documentPickerViewController, animated: true)+ } else {+ topViewController(in: scene)?.present(documentPickerViewController, animated: true)+ }self.manualHandle = manualHandleself.cancelHandle = cancelHandle+ self.scene = scene}}@@ -46,7 +53,7 @@ extension FilesImporter: UIDocumentPickerDelegate {manualHandle?(urls)manualHandle = nil} else {- FilesImporter.importFiles(urls: urls)+ FilesImporter.importFiles(urls: urls, in: scene)}}@@ -91,6 +98,7 @@ extension FilesImporter {static func importFiles(urls: [URL],preErrors: [ImportError] = [],silentMode: Bool = PlayViewController.isGaming,+ in scene: UIWindowScene?,importCompletion: (()->Void)? = nil) {if urls.isEmpty {UIView.hideLoading()@@ -294,7 +302,7 @@ extension FilesImporter {group.notify(queue: .main) {//导入游戏成功- if let home = topViewController(appController: true) as? HomeViewController,+ if let home = topApplicationViewController() as? HomeViewController,home.homeTabBar.currentSelection == .games {UIView.makeToast(message: R.string.localizable.importGameSuccessTitle())} else {@@ -314,7 +322,7 @@ extension FilesImporter {confirmAction: {UIView.hideAllAlert {if importGames.count == 1 {- startGame(gameId: importGames.first!.id)+ startGame(gameId: importGames.first!.id, in: scene)} else {NotificationCenter.default.post(name: R.NotificationName.HomeSelectionChange, object: HomeTabBar.BarSelection.games)}@@ -362,7 +370,7 @@ extension FilesImporter {confirmTitle: confirmTitle,confirmAction: {UIView.hideAllAlert {- startGame(gameId: importGameSaves.first!.id)+ startGame(gameId: importGameSaves.first!.id, in: scene)}})} else if importGameSaves.count > 0 || importGames.count > 0 || importSkins.count > 0 {@@ -405,10 +413,10 @@ extension FilesImporter {}}- private static func startGame(gameId: String) {+ private static func startGame(gameId: String, in scene: UIWindowScene?) {let realm = Database.realmif let game = realm.object(ofType: Game.self, forPrimaryKey: gameId) {- game.handleTapAction()+ game.handleTapAction(in: scene)}}diff --git a/ManicEmu/ManicEmu/Sources/Tools/Others/ImageFetcher.swift b/ManicEmu/ManicEmu/Sources/Tools/Others/ImageFetcher.swiftindex 72bf88ae..b99df24a 100644--- a/ManicEmu/ManicEmu/Sources/Tools/Others/ImageFetcher.swift+++ b/ManicEmu/ManicEmu/Sources/Tools/Others/ImageFetcher.swift@@ -36,7 +36,10 @@ struct ImageFetcher {return editConfig}- static func capture(preferenceSize: CGSize? = .init(R.Size.GameCoverMaxSize), isOpenEditor: Bool = true, completion: @escaping (_ image: UIImage?)->Void) {+ static func capture(preferenceSize: CGSize? = .init(R.Size.GameCoverMaxSize),+ isOpenEditor: Bool = true,+ in scene: UIWindowScene?,+ completion: @escaping (_ image: UIImage?)->Void) {//拍摄PermissionKit.requestCamera {var config = CameraConfiguration()@@ -45,7 +48,7 @@ struct ImageFetcher {} else {config.allowsEditing = false}- let vc = Photo.capture(config, type: .photo, sender: topViewController()) { result, _, _ in+ let vc = Photo.capture(config, type: .photo, sender: topViewController(in: scene)) { result, _, _ inif case .image(let image) = result {if let preferenceSize {completion(image.scaled(toSize: preferenceSize))@@ -61,7 +64,10 @@ struct ImageFetcher {}}- static func pick(preferenceSize: CGSize? = .init(R.Size.GameCoverMaxSize), isOpenEditor: Bool = true, completion: @escaping (_ image: UIImage?)->Void) {+ static func pick(preferenceSize: CGSize? = .init(R.Size.GameCoverMaxSize),+ isOpenEditor: Bool = true,+ in scene: UIWindowScene?,+ completion: @escaping (_ image: UIImage?)->Void) {PermissionKit.requestPhoto {var config = PickerConfiguration.defaultconfig.navigationBackgroundColor = R.Color.BackgroundSecondary.forceStyle(.dark)@@ -70,7 +76,7 @@ struct ImageFetcher {config.selectOptions = [.livePhoto, .photo]config.photoSelectionTapAction = isOpenEditor ? .openEditor : .quickSelectconfig.editor = defaultEditorConfiguration()- let vc = Photo.picker(config, sender: topViewController()) { result, _ in+ let vc = Photo.picker(config, sender: topViewController(in: scene)) { result, _ inresult.getImage(compressionScale: 1) { image inif let image = image.first {if let preferenceSize {@@ -88,11 +94,17 @@ struct ImageFetcher {}}- static func file(preferenceSize: CGSize? = .init(R.Size.GameCoverMaxSize), isOpenEditor: Bool = true, completion: @escaping (_ image: UIImage?)->Void) {- ImageFileFetcher.shared.file(preferenceSize: preferenceSize, completion: { image in+ static func file(preferenceSize: CGSize? = .init(R.Size.GameCoverMaxSize),+ isOpenEditor: Bool = true,+ in scene: UIWindowScene?,+ completion: @escaping (_ image: UIImage?)->Void) {+ ImageFileFetcher.shared.file(preferenceSize: preferenceSize, in: scene, completion: { image inif let image {if isOpenEditor {- edit(image: image, preferenceSize: preferenceSize, completion: completion)+ edit(image: image,+ preferenceSize: preferenceSize,+ in: scene,+ completion: completion)} else {completion(image)}@@ -102,7 +114,10 @@ struct ImageFetcher {})}- static func edit(image: UIImage, preferenceSize: CGSize? = .init(R.Size.GameCoverMaxSize), completion: @escaping (_ image: UIImage?)->Void) {+ static func edit(image: UIImage,+ preferenceSize: CGSize? = .init(R.Size.GameCoverMaxSize),+ in scene: UIWindowScene?,+ completion: @escaping (_ image: UIImage?)->Void) {var config = defaultEditorConfiguration()// 由我们在 dismiss 完成后再回调,避免调用方立刻关掉 presenting 的 SheetWindow,导致系统旋转卡住。config.isAutoBack = false@@ -111,7 +126,7 @@ struct ImageFetcher {let vc = Photo.edit(asset: .init(type: .image(image)),config: config,- sender: topViewController(),+ sender: topViewController(in: scene),finished: { asset, editor invar result = imageif let url = asset.result?.url, let newImage = try? UIImage(url: url) {@@ -138,6 +153,7 @@ struct ImageFetcher {}static func showCommonFetcher(sources: [Source],+ in scene: UIWindowScene?,completion: ((UIImage?, Source) -> Void)? = nil ) {guard sources.count > 0 else { return }@@ -175,15 +191,15 @@ struct ImageFetcher {guard let index else { return }switch sources[index] {case .capture:- ImageFetcher.capture(completion: {+ ImageFetcher.capture(in: scene, completion: {completion?($0, .capture)})case .library:- ImageFetcher.pick(completion: {+ ImageFetcher.pick(in: scene, completion: {completion?($0, .library)})case .file:- ImageFetcher.file(completion: {+ ImageFetcher.file(in: scene, completion: {completion?($0, .file)})case .libretro(let game):@@ -217,15 +233,16 @@ struct ImageFetcher {})}case .editImage(let image):- ImageFetcher.edit(image: image, completion: {+ ImageFetcher.edit(image: image, in: scene, completion: {completion?($0, .editImage(image))})case .editImageUrl(let url):+ let s = sceneKingfisherManager.shared.retrieveImage(with: url) { result inswitch result {case .success(let imageResult):Task { @MainActor in- ImageFetcher.edit(image: imageResult.image, completion: {+ ImageFetcher.edit(image: imageResult.image, in: s, completion: {completion?($0, .editImageUrl(url))})}@@ -247,14 +264,16 @@ fileprivate class ImageFileFetcher: NSObject {private var preferenceSize: CGSize? = nilprivate var completion: ((_ image: UIImage?)->Void)? = nil- func file(preferenceSize: CGSize? = .init(R.Size.GameCoverMaxSize), completion: @escaping (_ image: UIImage?)->Void) {+ func file(preferenceSize: CGSize? = .init(R.Size.GameCoverMaxSize),+ in scene: UIWindowScene?,+ completion: @escaping (_ image: UIImage?)->Void) {self.preferenceSize = preferenceSizeself.completion = completionlet documentPickerViewController = UIDocumentPickerViewController(forOpeningContentTypes: [UTType.image], asCopy: true)documentPickerViewController.delegate = selfdocumentPickerViewController.overrideUserInterfaceStyle = UIDevice.isDarkMode ? .dark : .lightdocumentPickerViewController.allowsMultipleSelection = false- topViewController()?.present(documentPickerViewController, animated: true)+ topViewController(in: scene)?.present(documentPickerViewController, animated: true)}}diff --git a/ManicEmu/ManicEmu/Sources/Tools/Others/PasteImporter.swift b/ManicEmu/ManicEmu/Sources/Tools/Others/PasteImporter.swiftindex 8c20ccbb..f9ed7f43 100644--- a/ManicEmu/ManicEmu/Sources/Tools/Others/PasteImporter.swift+++ b/ManicEmu/ManicEmu/Sources/Tools/Others/PasteImporter.swift@@ -10,7 +10,8 @@import UniformTypeIdentifiersstruct PasteImporter {- static func paste(supportedTypes: [UTType] = UTType.allInfoPlistTypes) {+ static func paste(supportedTypes: [UTType] = UTType.allInfoPlistTypes,+ in scene: UIWindowScene?) {UIView.makeLoading()DispatchQueue.global().async {var errors: [ImportError] = []@@ -95,7 +96,7 @@ struct PasteImporter {UIView.hideLoading()UIView.makeToast(message: String.errorMessage(from: errors))} else {- FilesImporter.importFiles(urls: urls, preErrors: errors)+ FilesImporter.importFiles(urls: urls, preErrors: errors, in: scene)}}}diff --git a/ManicEmu/ManicEmu/Sources/Tools/Others/ShareManager.swift b/ManicEmu/ManicEmu/Sources/Tools/Others/ShareManager.swiftindex 8b95dfed..2ada25ed 100644--- a/ManicEmu/ManicEmu/Sources/Tools/Others/ShareManager.swift+++ b/ManicEmu/ManicEmu/Sources/Tools/Others/ShareManager.swift@@ -45,12 +45,12 @@ extension ShareManager: UIActivityItemSource {return metadata}- static func shareApp(senderForIpad: UIView? = nil) {+ static func shareApp(senderForIpad: UIView? = nil, in scene: UIWindowScene?) {let activityViewController = UIActivityViewController(activityItems: [ShareManager.shared], applicationActivities: nil)//分享App的链接activityViewController.excludedActivityTypes = [.saveToCameraRoll, .airDrop, .copyToPasteboard, .print]DispatchQueue.main.async {- if let topVc = topViewController() {+ if let topVc = topViewController(in: scene) {if let ppvc = activityViewController.popoverPresentationController {ppvc.sourceView = senderForIpad}@@ -61,7 +61,7 @@ extension ShareManager: UIActivityItemSource {}extension ShareManager {- static func shareFiles(games: [Game], shareFileType: ShareFileType) {+ static func shareFiles(games: [Game], shareFileType: ShareFileType, in scene: UIWindowScene?) {guard games.count > 0 else {UIView.makeToast(message: {switch shareFileType {@@ -107,7 +107,7 @@ extension ShareManager {}}- if let topVc = topViewController() {+ if let topVc = topViewController(in: scene) {let activityViewController = UIActivityViewController(activityItems: [url], applicationActivities: nil)if let ppvc = activityViewController.popoverPresentationController {ppvc.sourceView = topVc.view@@ -157,7 +157,7 @@ extension ShareManager {return}- if let topVc = topViewController() {+ if let topVc = topViewController(in: scene) {let activityViewController = UIActivityViewController(activityItems: urls, applicationActivities: nil)if let ppvc = activityViewController.popoverPresentationController {ppvc.sourceView = topVc.view@@ -167,17 +167,17 @@ extension ShareManager {}}- static func shareFile(fileUrl: URL) {+ static func shareFile(fileUrl: URL, in scene: UIWindowScene?) {guard FileManager.default.fileExists(atPath: fileUrl.path) else {UIView.makeToast(message: R.string.localizable.shareFileFailedMissing())return}- shareFiles(fileUrls: [fileUrl])+ shareFiles(fileUrls: [fileUrl], in: scene)}- static func shareFiles(fileUrls: [URL]) {- if let topVc = topViewController() {+ static func shareFiles(fileUrls: [URL], in scene: UIWindowScene?) {+ if let topVc = topViewController(in: scene) {let activityViewController = UIActivityViewController(activityItems: fileUrls, applicationActivities: nil)if let ppvc = activityViewController.popoverPresentationController {ppvc.sourceView = topVc.view@@ -186,7 +186,7 @@ extension ShareManager {}}- static func shareImage(image: UIImage) {+ static func shareImage(image: UIImage, in scene: UIWindowScene?) {// 1. 保存图片到临时目录guard let data = image.pngData() else { return }let tempURL = FileManager.default.temporaryDirectory.appendingPathComponent("shared.png")@@ -198,7 +198,7 @@ extension ShareManager {} catch {return}- shareFile(fileUrl: tempURL)+ shareFile(fileUrl: tempURL, in: scene)}private static func create3DSGameSave(urls: [String: URL]) -> URL? {diff --git a/ManicEmu/ManicEmu/Sources/Tools/Others/SideMenuShowStyle.swift b/ManicEmu/ManicEmu/Sources/Tools/Others/SideMenuShowStyle.swiftindex 1e9cfbc4..85a5ca55 100644--- a/ManicEmu/ManicEmu/Sources/Tools/Others/SideMenuShowStyle.swift+++ b/ManicEmu/ManicEmu/Sources/Tools/Others/SideMenuShowStyle.swift@@ -48,7 +48,7 @@ class SideMenuShowStyle: SideMenuPresentationStyle {/// The ending alpha of the presenting view when the menu is fully displayed.presentingEndAlpha = 1/// The amount the presenting view is translated along the x-axis. Zero is stationary, negative values are off-screen, positive values are on screen.- presentingTranslateFactor = 1-(R.Size.WindowWidth*(1-0.879))/2/R.Size.WindowWidth+ presentingTranslateFactor = 1-(R.Size.ApplicationWindowSize.width*(1-0.879))/2/R.Size.ApplicationWindowSize.width/// The amount the presenting view is scaled. Less than one shrinks the view, larger than one grows the view.presentingScaleFactor = 0.879/// The strength of the parallax effect on the presenting view once the menu is displayed.diff --git a/ManicEmu/ManicEmu/Sources/Tools/Others/ThemeManager.swift b/ManicEmu/ManicEmu/Sources/Tools/Others/ThemeManager.swiftindex 62f474f0..3ba76e99 100644--- a/ManicEmu/ManicEmu/Sources/Tools/Others/ThemeManager.swift+++ b/ManicEmu/ManicEmu/Sources/Tools/Others/ThemeManager.swift@@ -89,7 +89,7 @@ class ThemeManager {if self.mainColor.hexString != mainColor.hexString {self.mainColor = mainColor//刷新整个系统的外观 会驱使traitCollectionDidChange方法进行调用- if let userInterfaceStyle = ApplicationSceneDelegate.applicationWindow?.traitCollection.userInterfaceStyle {+ if let userInterfaceStyle = UIWindow.applicationWindow?.traitCollection.userInterfaceStyle {if userInterfaceStyle == .dark {ThemeManager.updateUserInterfaceStyle(.light)} else {diff --git a/ManicEmu/ManicEmu/Sources/Tools/Others/WebServer.swift b/ManicEmu/ManicEmu/Sources/Tools/Others/WebServer.swiftindex 57c36744..0cee3835 100644--- a/ManicEmu/ManicEmu/Sources/Tools/Others/WebServer.swift+++ b/ManicEmu/ManicEmu/Sources/Tools/Others/WebServer.swift@@ -11,6 +11,7 @@ import GCDWebUploaderclass WebServer: NSObject {static let shard = WebServer()+ private weak var scene: UIWindowScene? = nilvar ipAddress: String {if let webServer = webServer, let serverURL = webServer.serverURL, let host = serverURL.host, let port = serverURL.port {@@ -29,8 +30,9 @@ class WebServer: NSObject {private override init(){}private var webServer: GCDWebUploader?- func start() {+ func start(in scene: UIWindowScene?) {guard webServer == nil else { return }+ self.scene = scenewebServer = GCDWebUploader(uploadDirectory: R.Path.UploadWorkSpace)webServer?.allowedFileExtensions = FileType.allSupportFileExtension()webServer?.delegate = self@@ -56,6 +58,6 @@ class WebServer: NSObject {extension WebServer: GCDWebUploaderDelegate {func webUploader(_ uploader: GCDWebUploader, didUploadFileAtPath path: String) {- FilesImporter.importFiles(urls: [URL(fileURLWithPath: path)])+ FilesImporter.importFiles(urls: [URL(fileURLWithPath: path)], in: scene)}}