Skip to content

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/DeltaCore
index a9ed6eb8..339082e0 160000
--- a/Dependencies/DeltaCore
+++ b/Dependencies/DeltaCore
@@ -1 +1 @@
-Subproject commit a9ed6eb83913865a5613b666724ebd414c226eca
+Subproject commit 339082e079fcf020de9bb6653dd1aac7f2cbbd3c
diff --git a/Dependencies/ProHUD b/Dependencies/ProHUD
index bbded704..40669542 160000
--- a/Dependencies/ProHUD
+++ b/Dependencies/ProHUD
@@ -1 +1 @@
-Subproject commit bbded7047d8c594a024369c2f58b0238f4817e4c
+Subproject commit 40669542554dd928ad69652a925a1c591f4e8264
diff --git a/ManicEmu/ManicEmu.xcodeproj/project.pbxproj b/ManicEmu/ManicEmu.xcodeproj/project.pbxproj
index 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.resolved
index 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.plist
index 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.swift
index 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?.rootViewController
while 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.swift
index 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 = nil
let realm = Database.realm
if 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 {
// 所有操作完成后刷新UI
dispatchGroup.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.swift
index 4c73829b..ff842140 100644
--- a/ManicEmu/ManicEmu/Sources/Base/Constants.swift
+++ b/ManicEmu/ManicEmu/Sources/Base/Constants.swift
@@ -9,6 +9,7 @@
import UIKit
import RealmSwift
+import ProHUD
extension _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 18
static let SymbolSize = 18.0
///HomeTabBarSize 300x60
static 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:1
static 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: - Sheet
static var SheetWindowMaxSize: CGSize {
+ let window = proHUDWindow()
+ let windowSize = window?.size ?? R.Size.ApplicationWindowSize
if 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.swift
index 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 nil
diff --git a/ManicEmu/ManicEmu/Sources/Business/CheatCode/Views/AddCheatCodeView.swift b/ManicEmu/ManicEmu/Sources/Business/CheatCode/Views/AddCheatCodeView.swift
index 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 = self
view.delegate = self
view.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.swift
index 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 in
guard let self, optionIndex != nil else { return }
- FilesImporter.shared.presentImportController(supportedTypes: supportFileExtensions) { [weak self] urls in
+ FilesImporter.shared.presentImportController(supportedTypes: supportFileExtensions, manualHandle: { [weak self] urls in
guard 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.swift
index 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 = false
view.isOpaque = false
view.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.swift
index 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 in
make.leading.top.trailing.equalToSuperview()
- make.height.equalTo(R.Size.PageBackgroundMaskHeight)
+ make.height.equalTo(R.Size.PageBackgroundMaskHeight(window: hostingWindow))
}
maskView.isHidden = !enableBackgroundMask
backgroundMaskView = maskView
@@ -150,14 +150,14 @@ class BaseViewController: UIViewController {
coordinator.animate(alongsideTransition: { [weak self] _ in
self?.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.swift
index 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: - Subviews
private var navigationView: ASNavigationView? = nil
@@ -195,7 +192,7 @@ class ASListPageView: BaseView {
self.listPage = listPage
if 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.width
let 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 ?? 0
if 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 : 0
fixContainerWidth = 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.bottom
if 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: - UICollectionViewDataSource
diff --git a/ManicEmu/ManicEmu/Sources/Business/Common/Views/ASSheetView.swift b/ManicEmu/ManicEmu/Sources/Business/Common/Views/ASSheetView.swift
index 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 sheet
func 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.width
config.cardMaxHeight = R.Size.SheetFullScreenForIpadLandscape.height
@@ -217,7 +217,7 @@ class ASSheetView: BaseView {
var didNotifyCovering = false
func 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 constraints
func updateContentViewConstraints() {
- if sheetData.fullScreenForLandscape, UIDevice.isLandscape {
+ if sheetData.fullScreenForLandscape, getLayoutStyle() == .landscape {
contentView.snp.remakeConstraints { make in
make.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 in
guard 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.width
switch 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 in
make.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 in
diff --git a/ManicEmu/ManicEmu/Sources/Business/Common/Views/ASWebView.swift b/ManicEmu/ManicEmu/Sources/Business/Common/Views/ASWebView.swift
index 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 = false
view.backgroundColor = R.Color.BackgroundPrimary
view.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.swift
index 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 SwiftUI
struct 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 in
UIView.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.applicationWindow
if 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 radius
diff --git a/ManicEmu/ManicEmu/Sources/Business/Common/Views/FileBrowserView.swift b/ManicEmu/ManicEmu/Sources/Business/Common/Views/FileBrowserView.swift
index 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 mode
isEditMode = true
- } else if index == 1 {
+ } else if index == 1 || (index == 0 && currentPageItems.filter({ !$0.isDirectory }).count == 0) {
//download manager
DownloadManageView.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.swift
index 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 in
alert.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.swift
index 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 = false
view.backgroundColor = R.Color.BackgroundPrimary
view.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.swift
index 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 = controlerSkin
controllerView.snp.remakeConstraints { make in
make.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.swift
index 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 index
if !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.swift
index 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 in
guard 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/write
diff --git a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameCoverModifyView.swift b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameCoverModifyView.swift
index 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.minDimension
return 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 in
guard 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.minDimension
let 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.swift
index 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.swift
index 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.swift
index 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 = false
view.didTapButton = { [weak self] in
guard let self = self else { return }
- self.game.handleTapAction(forceQuick: true)
+ self.game.handleTapAction(forceQuick: true, in: self.hostingWindowScene)
}
view.isAccessibilityElement = true
view.accessibilityLabel = R.string.localizable.startGameTitle()
@@ -81,7 +81,7 @@ class GameInfoDetailView: BaseView {
confirmAction: { [weak self] in
guard let self else { return }
self.game.safeMode = true
- self.game.handleTapAction(forceQuick: true)
+ self.game.handleTapAction(forceQuick: true, in: self.hostingWindowScene)
})
}
view.isAccessibilityElement = true
diff --git a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameInfoNavigationView.swift b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameInfoNavigationView.swift
index 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 view
diff --git a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameInfoView.swift b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameInfoView.swift
index 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 in
guard 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.0
private let gameInfoDetailHeight = 162.0
private 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 in
make.leading.top.bottom.equalToSuperview()
make.width.equalToSuperview().multipliedBy(0.5)
@@ -299,6 +301,6 @@ extension GameInfoView: ViewTransition {
navigationView.backgroundColor = .clear
navigationView.gameCover.alpha = 0
gameInfoDetailView.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.swift
index 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.swift
index 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 = self
view.delegate = self
view.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.swift
index 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 = self
view.delegate = self
view.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 = hostingWindowScene
KingfisherManager.shared.retrieveImage(with: url) { [weak self] result in
guard 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 in
guard let self = self else { return }
Task { @MainActor in
self.didSelectIamge?(image)
diff --git a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/PSXSBIImportView.swift b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/PSXSBIImportView.swift
index 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 = self
view.delegate = self
view.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 in
guard 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 cell
diff --git a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/SaveStateListView.swift b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/SaveStateListView.swift
index 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.swift
index 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 = hostingWindowScene
KingfisherManager.shared.retrieveImage(with: url) { [weak self] result in
Task { @MainActor in
UIView.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 in
Task { @MainActor in
self.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.swift
index 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.swift
index 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 Haptica
extension 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 in
if 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 saves
if 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 in
if 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:
break
case .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 files
if 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 in
guard 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 files
if 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 in
guard 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: { _ in
resumeEmulationIfNeed()
})
@@ -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 in
if 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 in
if 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 in
if type == .other {
resumeEmulationIfNeed()
diff --git a/ManicEmu/ManicEmu/Sources/Business/Games/ViewControllers/GamesViewController.swift b/ManicEmu/ManicEmu/Sources/Business/Games/ViewControllers/GamesViewController.swift
index 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 in
guard 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 Link
if let launchGameID = ApplicationSceneDelegate.launchGameID {
ApplicationSceneDelegate.launchGameID = nil
let realm = Database.realm
if 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] _ in
self?.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.LongAnimationDuration
menu.dismissDuration = R.Numbers.LongAnimationDuration
menu.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.swift
index 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 = indexPath
gameType = game.gameType
titleLabel.isHidden = !showTitle
diff --git a/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameCoverView.swift b/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameCoverView.swift
index 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 = .center
updateStyle(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] = image
return image
diff --git a/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameLandscapeCarouselCell.swift b/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameLandscapeCarouselCell.swift
index 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 = false
emptyContentStack.isHidden = false
cardView.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 in
diff --git a/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameListLandscapeView.swift b/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameListLandscapeView.swift
index 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 in
guard let self else { return }
- game.handleTapAction()
+ game.handleTapAction(in: self.hostingWindowScene)
}
}
return view
@@ -126,7 +126,7 @@ class GameListLandscapeView: BaseView {
view.delegate = self
view.alwaysBounceVertical = true
view.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.ContentSpaceLarge
view.contentInset = .insets(bottom: bottom)
view.isHidden = LandscapeCarouselStyle.isCarouselEnabled
view.addLongPressGesture(handler: { [weak self] gesture in
@@ -165,7 +165,7 @@ class GameListLandscapeView: BaseView {
let view = ASButtonView(button)
view.didTapButton = { [weak self] in
guard 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 in
make.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] in
self?.showDynamicBackgroundSheet()
- })
+ }, in: self.hostingWindowScene)
})
}
return .dismiss()
@@ -1038,7 +1038,7 @@ class GameListLandscapeView: BaseView {
self.showBackgroundMusicSheet()
}, cancelHandle: { [weak self] in
self?.showBackgroundMusicSheet()
- })
+ }, in: self.hostingWindowScene)
})
}
return .dismiss()
@@ -1663,7 +1663,7 @@ extension GameListLandscapeView: UICollectionViewDataSource {
let carouselHeight = carouselView.bounds.height > 0 ? carouselView.bounds.height : 300
return 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.swift
index 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 = self
view.delegate = self
view.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.ContentSpaceLarge
view.contentInset = .insets(bottom: bottom)
view.blankSlateView = GamesListBlankSlateView()
view.addLongPressGesture(handler: { [weak self] gesture in
@@ -67,12 +67,12 @@ class GameListView: BaseView {
if index == 0 {
//delete
if 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 {
//skin
if 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 = 0
private var isToolViewScrollInitialized = false
private 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*2
let sectionInsetTop = R.Size.ContentSpaceTiny
@@ -589,7 +585,11 @@ class GameListView: BaseView {
let group: NSCollectionLayoutGroup
var column = R.Style.GamesPerRow
if 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.count
if 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.swift
index 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] in
guard 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.height
diff --git a/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameplayManualsView.swift b/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameplayManualsView.swift
index 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 view
diff --git a/ManicEmu/ManicEmu/Sources/Business/Games/Views/GamesCollectionReusableView.swift b/ManicEmu/ManicEmu/Sources/Business/Games/Views/GamesCollectionReusableView.swift
index 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.swift
index 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/2
containerView.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.swift
index 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 = self
view.delegate = self
view.contentInset = .insets(top: R.Size.ContentSpaceSmall,
- bottom: R.Size.ContentInsetBottom)
+ bottom: R.Size.ContentInsetBottom(window: hostingWindow))
view.blankSlateView = PlayHistoryBlankSlateView(tapAction: { [weak self] type in
guard 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 in
diff --git a/ManicEmu/ManicEmu/Sources/Business/Home/ViewControllers/HomeViewController.swift b/ManicEmu/ManicEmu/Sources/Business/Home/ViewControllers/HomeViewController.swift
index 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 in
make.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 = selection
if 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 == .landscape
return view
}()
- private var homeTabBarBlurView: UIView = {
+ private lazy var homeTabBarBlurView: UIView = {
let view = BlurUIKit.VariableBlurView()
view.direction = .up
view.maximumBlurRadius = 1
view.dimmingAlpha = .interfaceStyle(lightModeAlpha: 0.05, darkModeAlpha: 0.05)
view.dimmingTintColor = R.Color.BackgroundPrimary
- view.isHidden = UIDevice.isLandscape
+ view.isHidden = self.view.prefferedLayoutStyle == .landscape
return 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 == .landscape
if 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: { _ in
NotificationCenter.default.post(name: R.NotificationName.ViewDidTransition, object: nil)
})
@@ -257,8 +258,8 @@ class HomeViewController: BaseViewController {
homeTabBar.snp.makeConstraints { make in
make.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 == .landscape
if 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.swift
index 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.BackgroundPrimary
view.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 in
make.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 in
make.leading.top.bottom.equalToSuperview()
make.trailing.equalTo(importServiceListView.snp.leading)
}
+ cornerMaskViewForiPad.removeFromSuperview()
view.addSubview(cornerMaskViewForiPad)
- cornerMaskViewForiPad.snp.makeConstraints { make in
+ cornerMaskViewForiPad.snp.remakeConstraints { make in
make.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.LongAnimationDuration
menu.dismissDuration = R.Numbers.LongAnimationDuration
menu.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.swift
index 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: ImportService
if 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] in
diff --git a/ManicEmu/ManicEmu/Sources/Business/Import/Views/AddUrlGameView.swift b/ManicEmu/ManicEmu/Sources/Business/Import/Views/AddUrlGameView.swift
index 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 in
guard let self else { return }
if case .delete = source {
self.coverRemoved = true
diff --git a/ManicEmu/ManicEmu/Sources/Business/Import/Views/ImportMottoCollectionViewCell.swift b/ManicEmu/ManicEmu/Sources/Business/Import/Views/ImportMottoCollectionViewCell.swift
index 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 = .center
return 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 in
make.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))).cgPath
backgroundGradientView.layer.mask = ovalLayer
- if UIDevice.isPhone, UIDevice.isLandscape {
+ if UIDevice.isPhone, prefferedLayoutStyle == .landscape {
keepCellHeightView.backgroundColor = R.Color.BackgroundSecondary
backgroundGradientView.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 in
make.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.swift
index 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.swift
index 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 in
make.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.isLandscapeLayout
let widthDimension: NSCollectionLayoutDimension
if 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 {
//group
let count: Int
if 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.ContentSpaceLarge
return .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 : false
if 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.swift
index 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 = true
view.dragDelegate = self
view.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.ContentSpaceMedium
view.contentInset = .insets(top: R.Size.ContentSpaceSmall,
bottom: bottom)
return view
@@ -186,7 +186,7 @@ class MultiDiscBuilderView: BaseView {
addToLibraryButton.snp.makeConstraints { make in
make.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 in
guard 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.swift
index 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 = 1
try? 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.swift
index 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 in
guard 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.swift
index 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 = self
view.delegate = self
view.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.swift
index 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 = self
view.delegate = self
view.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 false
diff --git a/ManicEmu/ManicEmu/Sources/Business/Play/Models/Game.swift b/ManicEmu/ManicEmu/Sources/Business/Play/Models/Game.swift
index 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.swift
index 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 in
UIView.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] in
guard 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.ApplicationWindowSize
let toSize = size
if 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 = snapshot
if (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] in
guard 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 in
if 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] in
guard 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.airPlayLayout
var layout: String = ""
let ratio = 0.3
- let scale = isOriginalShader ? UIScreen.main.scale : 1.25
+ let scale = isOriginalShader ? hostingWindow.screen.scale : 1.25
let 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:4
switch 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.25
let scaleTransform = CGAffineTransform(scaleX: scale, y: scale)
var touchGameViewFrame = CGRect.zero
if 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 in
guard 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.skinFrame
let 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 = .zero
toast.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) * scale
toast.config.cardMaxHeight = 64 * scale
toast.contentView.layerBorderColor = R.Color.Border
toast.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.skinFrame
let topFrame = frames.mainGameViewFrame
if 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.image
diff --git a/ManicEmu/ManicEmu/Sources/Business/Play/Views/CheevosPopupView.swift b/ManicEmu/ManicEmu/Sources/Business/Play/Views/CheevosPopupView.swift
index 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 = true
view.allowsSelection = true
view.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.NavigationHeight
height += CGFloat(leaderBoards.count) * 64
height += CGFloat(leaderBoards.count + 1) * R.Size.ContentSpaceMedium
- height += R.Size.ContentInsetBottom
+ height += R.Size.ContentInsetBottom(window: hostingWindow)
return height
case .progress, .challenge:
var height = R.Size.SheetGrabberTopInset + R.Size.NavigationHeight
height += CGFloat(achievements.count) * R.Size.ItemHeightExtraLarge
height += 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.swift
index 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 Device
class FeaturesCell: UICollectionViewCell {
- private var viewAlongsideTransitionNotification: Any? = nil
private 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.bounds
if 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: CGFloat
let animation = CABasicAnimation(keyPath: "position.x")
+ let windowSize = hostingWindow?.size ?? R.Size.ApplicationWindowSize
if 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.swift
index 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 = self
view.isFocusable = true
view.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.swift
index 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 = featuresType
addSubview(priceView)
-
- updateViewsConstraits()
}
override func layoutSubviews() {
super.layoutSubviews()
+ updateViewsConstraits()
imageLayer.contents = R.image.game_cover_bg()?.scaled(toWidth: backgroundGradientView.width)?.cropped(to: backgroundGradientView.bounds).cgImage
imageLayer.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.swift
index 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 = false
view.dataSource = self
view.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 = true
view.blankSlateView = blankView
diff --git a/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/Views/RetroAchievementsDetailView.swift b/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/Views/RetroAchievementsDetailView.swift
index 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 in
UIView.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 in
make.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.swift
index 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.swift
index 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))/column
diff --git a/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/Views/RetroAchievementsLoginView.swift b/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/Views/RetroAchievementsLoginView.swift
index 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 = self
view.isFocusable = true
view.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.swift
index 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 RealmSwift
class RetroAchievementsProfileView: BaseView {
class DetailView: BaseView {
+ var didLayoutChange: (() -> Bool)? = nil
+
private static let avatarSize = 80.0
class 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 in
make.height.equalTo(R.Size.CardHeight)
make.leading.equalToSuperview()
@@ -321,6 +327,10 @@ class RetroAchievementsProfileView: BaseView {
view.didTapLogout = { [weak self] in
self?.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)? = nil
private var showAsSheet: Bool
+ private var prefferedLandscapeStyle: Bool {
+ if showAsSheet {
+ return prefferedLayoutStyle == .landscape
+ } else {
+ return width > 600
+ }
+ }
+
init(username: String, showAsSheet: Bool) {
self.username = username
self.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.swift
index 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 in
make.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 in
make.edges.equalTo(settingsListView)
}
+ detailContentView.removeFromSuperview()
view.addSubview(detailContentView)
- detailContentView.snp.makeConstraints { make in
+ detailContentView.snp.remakeConstraints { make in
make.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 in
make.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.swift
index 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 = false
itemView.button.onTap {
func importFromFiles() {
- FilesImporter.shared.presentImportController(supportedTypes: UTType.binTypes, allowsMultipleSelection: true) { urls in
+ FilesImporter.shared.presentImportController(supportedTypes: UTType.binTypes, allowsMultipleSelection: true, manualHandle: { urls in
UIView.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.swift
index 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 : 0
return 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 in
UIView.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] in
guard 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.swift
index 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 ChromaColorPicker
class 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 in
make.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 in
make.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.swift
index 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 in
guard 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.swift
index 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 : 0
return 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 in
if 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.swift
index 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, _ in
guard 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.swift
index 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.ContentSpaceLarge
let 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 {
#endif
case .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.swift
index 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 in
make.leading.top.bottom.equalToSuperview()
}
diff --git a/ManicEmu/ManicEmu/Sources/Business/Settings/Views/SymbianDeviceView.swift b/ManicEmu/ManicEmu/Sources/Business/Settings/Views/SymbianDeviceView.swift
index 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 = self
view.delegate = self
view.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 = true
game.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.swift
index 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 in
guard let self, let url = urls.first else { return }
let previous = fileExtension == "rom" ? self.pendingRomURL : self.pendingRpkgURL
guard 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.swift
index 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 = self
view.dropDelegate = self
view.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.swift
index 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 : 0
return 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.swift
index 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] in
self?.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 : 0
return 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.swift
index 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] in
guard 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, _ in
guard 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.swift
index 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 = scaledFrame
initFrames.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 in
guard 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.swift
index 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 = skin
self.traits = traits
super.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 in
make.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 in
make.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.swift
index 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 in
make.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.swift
index 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: CGFloat
if 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 in
diff --git a/ManicEmu/ManicEmu/Sources/Business/Skin/Views/SkinSettingsView.swift b/ManicEmu/ManicEmu/Sources/Business/Skin/Views/SkinSettingsView.swift
index 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 = 0
private 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))/column
let 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] in
guard 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.swift
index 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.realm
self.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 in
make.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 in
make.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 in
make.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 in
make.leading.equalTo(skinFrames.mainGameViewFrame.minX)
diff --git a/ManicEmu/ManicEmu/Sources/Business/TriggerPro/Views/AddTriggerButtonStyleView.swift b/ManicEmu/ManicEmu/Sources/Business/TriggerPro/Views/AddTriggerButtonStyleView.swift
index 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, _ in
if let image = image?.scaled(toSize: self?.buttonSize ?? TriggerItem.Style.custom.defaultSize) {
self?.triggerButton.image = image
self?.didImageChange?(image)
diff --git a/ManicEmu/ManicEmu/Sources/Business/TriggerPro/Views/AddTriggerMappingListView.swift b/ManicEmu/ManicEmu/Sources/Business/TriggerPro/Views/AddTriggerMappingListView.swift
index 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)
//header
if sectionIndex != 0 {
diff --git a/ManicEmu/ManicEmu/Sources/Business/TriggerPro/Views/TriggerProManageView.swift b/ManicEmu/ManicEmu/Sources/Business/TriggerPro/Views/TriggerProManageView.swift
index 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 action
if 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 trigger
if !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 : 0
return 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.swift
index 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.swift
index 1a8570b9..41382370 100644
--- a/ManicEmu/ManicEmu/Sources/Tools/Extensions/ControllerSkinExtensions.swift
+++ b/ManicEmu/ManicEmu/Sources/Tools/Extensions/ControllerSkinExtensions.swift
@@ -11,9 +11,10 @@
import AVFoundation
extension 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.swift
index 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.swift
new file mode 100644
index 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.swift
index 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?.rootViewController
while 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.swift
new file mode 100644
index 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.swift
index 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 { _ in
hideCompletion?()
}
- let maxWidth = R.Size.WindowWidth - 2*R.Size.ContentSpaceLarge
+ let maxWidth = (AppContext.appWindow?.size ?? R.Size.ApplicationWindowSize).width - 2*R.Size.ContentSpaceLarge
let insets = UIEdgeInsets(horizontal: R.Size.ContentSpaceHuge*2, vertical: 14*2)
toast.config.cardEdgeInsets = insets
let 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.displayScale
format.opaque = isOpaque
let 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.swift
index b8feadd5..2b05ca78 100644
--- a/ManicEmu/ManicEmu/Sources/Tools/Extensions/UIWindowExtensions.swift
+++ b/ManicEmu/ManicEmu/Sources/Tools/Extensions/UIWindowExtensions.swift
@@ -9,6 +9,7 @@
import Foundation
import UIKit
+import ProHUD
extension 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 in
if 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.swift
index 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 = source
reloadItems()
if superview !== window {
diff --git a/ManicEmu/ManicEmu/Sources/Tools/JIT/StikJITManager.swift b/ManicEmu/ManicEmu/Sources/Tools/JIT/StikJITManager.swift
index 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.swift
index 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 in
switch connectResult {
case .success(let connectSuccess):
diff --git a/ManicEmu/ManicEmu/Sources/Tools/Others/DownloadManager.swift b/ManicEmu/ManicEmu/Sources/Tools/Others/DownloadManager.swift
index 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.swift
index 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.0
diff --git a/ManicEmu/ManicEmu/Sources/Tools/Others/FilesImporter.swift b/ManicEmu/ManicEmu/Sources/Tools/Others/FilesImporter.swift
index 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)? = nil
private var cancelHandle: (() -> Void)? = nil
+ private weak var scene: UIWindowScene? = nil
func 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 = self
documentPickerViewController.overrideUserInterfaceStyle = UIDevice.isDarkMode ? .dark : .light
documentPickerViewController.allowsMultipleSelection = allowsMultipleSelection
documentPickerViewController.modalPresentationStyle = .formSheet
documentPickerViewController.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 = manualHandle
self.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.realm
if 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.swift
index 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, _, _ in
if 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.default
config.navigationBackgroundColor = R.Color.BackgroundSecondary.forceStyle(.dark)
@@ -70,7 +76,7 @@ struct ImageFetcher {
config.selectOptions = [.livePhoto, .photo]
config.photoSelectionTapAction = isOpenEditor ? .openEditor : .quickSelect
config.editor = defaultEditorConfiguration()
- let vc = Photo.picker(config, sender: topViewController()) { result, _ in
+ let vc = Photo.picker(config, sender: topViewController(in: scene)) { result, _ in
result.getImage(compressionScale: 1) { image in
if 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 in
if 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 in
var result = image
if 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 = scene
KingfisherManager.shared.retrieveImage(with: url) { result in
switch 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? = nil
private 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 = preferenceSize
self.completion = completion
let documentPickerViewController = UIDocumentPickerViewController(forOpeningContentTypes: [UTType.image], asCopy: true)
documentPickerViewController.delegate = self
documentPickerViewController.overrideUserInterfaceStyle = UIDevice.isDarkMode ? .dark : .light
documentPickerViewController.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.swift
index 8c20ccbb..f9ed7f43 100644
--- a/ManicEmu/ManicEmu/Sources/Tools/Others/PasteImporter.swift
+++ b/ManicEmu/ManicEmu/Sources/Tools/Others/PasteImporter.swift
@@ -10,7 +10,8 @@
import UniformTypeIdentifiers
struct 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.swift
index 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.swift
index 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.swift
index 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.swift
index 57c36744..0cee3835 100644
--- a/ManicEmu/ManicEmu/Sources/Tools/Others/WebServer.swift
+++ b/ManicEmu/ManicEmu/Sources/Tools/Others/WebServer.swift
@@ -11,6 +11,7 @@ import GCDWebUploader
class WebServer: NSObject {
static let shard = WebServer()
+ private weak var scene: UIWindowScene? = nil
var 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 = scene
webServer = 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)
}
}