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

Added an skin option to adjust the pause menu position for better support of PlayCase and GAMEBABY; fixed an issue where iPad M3 couldn't be recognized properly.

Daiunob50d2cc1c8e0
diff --git a/Cores/DeltaCore/DeltaCore/Extensions/CGGeometry+Conveniences.swift b/Cores/DeltaCore/DeltaCore/Extensions/CGGeometry+Conveniences.swift
index fc99b4fa..db9da567 100644
--- a/Cores/DeltaCore/DeltaCore/Extensions/CGGeometry+Conveniences.swift
+++ b/Cores/DeltaCore/DeltaCore/Extensions/CGGeometry+Conveniences.swift
@@ -52,15 +52,17 @@ internal extension CGSize {
}
internal extension UIEdgeInsets {
- init?(dictionary: [String: CGFloat]) {
- guard
- let top = dictionary["top"],
- let bottom = dictionary["bottom"],
- let left = dictionary["left"],
- let right = dictionary["right"]
- else { return nil }
+ init?(dictionary: [String: CGFloat])
+ {
+ let top = dictionary["top"]
+ let bottom = dictionary["bottom"]
+ let left = dictionary["left"]
+ let right = dictionary["right"]
+
+ // Make sure it contains at least one valid value.
+ guard top != nil || bottom != nil || left != nil || right != nil else { return nil }
- self = UIEdgeInsets(top: top, left: left, bottom: bottom, right: right)
+ self = UIEdgeInsets(top: top ?? 0, left: left ?? 0, bottom: bottom ?? 0, right: right ?? 0)
}
}
diff --git a/Cores/DeltaCore/DeltaCore/Model/ControllerSkin.swift b/Cores/DeltaCore/DeltaCore/Model/ControllerSkin.swift
index 6abc2608..8030d4c8 100644
--- a/Cores/DeltaCore/DeltaCore/Model/ControllerSkin.swift
+++ b/Cores/DeltaCore/DeltaCore/Model/ControllerSkin.swift
@@ -383,6 +383,12 @@ public extension ControllerSkin
//TODO: Support `contentSize` for JSON controller skins.
return nil
}
+
+ func menuInsets(for traits: ControllerSkin.Traits) -> UIEdgeInsets?
+ {
+ guard let representation = self.representation(for: traits) else { return nil }
+ return representation.menuInsets
+ }
}
private extension ControllerSkin
@@ -800,6 +806,8 @@ private extension ControllerSkin
let items: [Item]
+ let menuInsets: UIEdgeInsets?
+
/// CustomStringConvertible
var description: String {
return self.traits.description
@@ -826,6 +834,12 @@ private extension ControllerSkin
self.traits = traits
self.aspectRatio = mappingSize
+ if let menuInsetsDictionary = dictionary["menuInsets"] as? [String: CGFloat] {
+ self.menuInsets = UIEdgeInsets(dictionary: menuInsetsDictionary)
+ } else {
+ self.menuInsets = nil
+ }
+
// Controller skins with no items or assets are now supported.
let itemsArray = dictionary["items"] as? [[String: AnyObject]] ?? []
let assetsDictionary = dictionary["assets"] as? [String: String] ?? [:]
diff --git a/Cores/DeltaCore/DeltaCore/Protocols/Model/ControllerSkinBase.swift b/Cores/DeltaCore/DeltaCore/Protocols/Model/ControllerSkinBase.swift
index 7a2a384c..d3bce5cf 100644
--- a/Cores/DeltaCore/DeltaCore/Protocols/Model/ControllerSkinBase.swift
+++ b/Cores/DeltaCore/DeltaCore/Protocols/Model/ControllerSkinBase.swift
@@ -30,6 +30,8 @@ public protocol ControllerSkinBase
func aspectRatio(for traits: ControllerSkin.Traits) -> CGSize?
func contentSize(for traits: ControllerSkin.Traits) -> CGSize?
+ func menuInsets(for traits: ControllerSkin.Traits) -> UIEdgeInsets?
+
func supportedTraits(for traits: ControllerSkin.Traits) -> ControllerSkin.Traits?
}
diff --git a/Cores/DeltaCore/DeltaCore/UI/Controller/TouchControllerSkin.swift b/Cores/DeltaCore/DeltaCore/UI/Controller/TouchControllerSkin.swift
index 8433f297..3024f790 100644
--- a/Cores/DeltaCore/DeltaCore/UI/Controller/TouchControllerSkin.swift
+++ b/Cores/DeltaCore/DeltaCore/UI/Controller/TouchControllerSkin.swift
@@ -124,4 +124,8 @@ extension TouchControllerSkin: ControllerSkinBase
return compositeScreenSize
}
+
+ public func menuInsets(for traits: ControllerSkin.Traits) -> UIEdgeInsets? {
+ return nil
+ }
}
diff --git a/ManicEmu/ManicEmu.xcodeproj/xcshareddata/xcschemes/ManicEmu.xcscheme b/ManicEmu/ManicEmu.xcodeproj/xcshareddata/xcschemes/ManicEmu.xcscheme
index c03c91b3..afc6f72d 100644
--- a/ManicEmu/ManicEmu.xcodeproj/xcshareddata/xcschemes/ManicEmu.xcscheme
+++ b/ManicEmu/ManicEmu.xcodeproj/xcshareddata/xcschemes/ManicEmu.xcscheme
@@ -82,7 +82,7 @@
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
- buildConfiguration = "SideloadRelease"
+ buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
diff --git a/ManicEmu/ManicEmu/Sources/Business/CheatCode/Views/AddCheatCodeView.swift b/ManicEmu/ManicEmu/Sources/Business/CheatCode/Views/AddCheatCodeView.swift
index e1435011..f893454b 100644
--- a/ManicEmu/ManicEmu/Sources/Business/CheatCode/Views/AddCheatCodeView.swift
+++ b/ManicEmu/ManicEmu/Sources/Business/CheatCode/Views/AddCheatCodeView.swift
@@ -355,12 +355,12 @@ extension AddCheatCodeView: UICollectionViewDataSource {
}
extension AddCheatCodeView {
- static func show(game: Game, gameCheat: GameCheat? = nil, gameViewRect: CGRect, hideCompletion: (()->Void)? = nil) {
+ static func show(game: Game, gameCheat: GameCheat? = nil, gameViewRect: CGRect, menuInsets: UIEdgeInsets? = nil, hideCompletion: (()->Void)? = nil) {
Sheet { sheet in
- sheet.configGamePlayingStyle(gameViewRect: gameViewRect, hideCompletion: hideCompletion)
+ sheet.configGamePlayingStyle(gameViewRect: gameViewRect, menuInsets: menuInsets, hideCompletion: hideCompletion)
let view = UIView()
- let containerView = RoundAndBorderView(roundCorner: (UIDevice.isPad || UIDevice.isLandscape) ? .allCorners : [.topLeft, .topRight])
+ let containerView = RoundAndBorderView(roundCorner: (UIDevice.isPad || UIDevice.isLandscape || menuInsets != nil) ? .allCorners : [.topLeft, .topRight])
containerView.backgroundColor = Constants.Color.BackgroundPrimary
view.addSubview(containerView)
containerView.snp.makeConstraints { make in
diff --git a/ManicEmu/ManicEmu/Sources/Business/CheatCode/Views/CheatCodeListView.swift b/ManicEmu/ManicEmu/Sources/Business/CheatCode/Views/CheatCodeListView.swift
index 9467f1e1..dcebdca3 100644
--- a/ManicEmu/ManicEmu/Sources/Business/CheatCode/Views/CheatCodeListView.swift
+++ b/ManicEmu/ManicEmu/Sources/Business/CheatCode/Views/CheatCodeListView.swift
@@ -245,12 +245,12 @@ extension CheatCodeListView {
Sheet.find(identifier: String(describing: CheatCodeListView.self)).count > 0 ? true : false
}
- static func show(game: Game, gameViewRect: CGRect, hideCompletion: (()->Void)? = nil, didTapClose: (()->Void)? = nil) {
+ static func show(game: Game, gameViewRect: CGRect, menuInsets: UIEdgeInsets? = nil, hideCompletion: (()->Void)? = nil, didTapClose: (()->Void)? = nil) {
Sheet.lazyPush(identifier: String(describing: CheatCodeListView.self)) { sheet in
- sheet.configGamePlayingStyle(gameViewRect: gameViewRect, hideCompletion: hideCompletion)
+ sheet.configGamePlayingStyle(gameViewRect: gameViewRect, menuInsets: menuInsets, hideCompletion: hideCompletion)
let view = UIView()
- let containerView = RoundAndBorderView(roundCorner: (UIDevice.isPad || UIDevice.isLandscape) ? .allCorners : [.topLeft, .topRight])
+ let containerView = RoundAndBorderView(roundCorner: (UIDevice.isPad || UIDevice.isLandscape || menuInsets != nil) ? .allCorners : [.topLeft, .topRight])
containerView.backgroundColor = Constants.Color.BackgroundPrimary
view.addSubview(containerView)
containerView.snp.makeConstraints { make in
@@ -277,10 +277,10 @@ extension CheatCodeListView {
let listView = CheatCodeListView(game: game)
listView.didTapAdd = {
- AddCheatCodeView.show(game: game, gameViewRect: gameViewRect)
+ AddCheatCodeView.show(game: game, gameViewRect: gameViewRect, menuInsets: menuInsets)
}
listView.didTapEdt = { gameCheat in
- AddCheatCodeView.show(game: game, gameCheat: gameCheat, gameViewRect: gameViewRect)
+ AddCheatCodeView.show(game: game, gameCheat: gameCheat, gameViewRect: gameViewRect, menuInsets: menuInsets)
}
listView.didTapClose = { [weak sheet] in
sheet?.pop()
diff --git a/ManicEmu/ManicEmu/Sources/Business/Common/ViewControllers/WebViewController.swift b/ManicEmu/ManicEmu/Sources/Business/Common/ViewControllers/WebViewController.swift
index e9edaf40..f5264f12 100644
--- a/ManicEmu/ManicEmu/Sources/Business/Common/ViewControllers/WebViewController.swift
+++ b/ManicEmu/ManicEmu/Sources/Business/Common/ViewControllers/WebViewController.swift
@@ -30,7 +30,11 @@ class WebViewController: BaseViewController {
if self.loadUrlWhenInit {
view.load(URLRequest(url: url))
}
- view.scrollView.contentInset = UIEdgeInsets(top: Constants.Size.ItemHeightMid, left: 0, bottom: Constants.Size.ContentInsetBottom, right: 0)
+ var bottomInset = Constants.Size.ContentInsetBottom
+ if let prefferdBottomInset = self.bottomInset, bottomInset < prefferdBottomInset {
+ bottomInset = prefferdBottomInset
+ }
+ view.scrollView.contentInset = UIEdgeInsets(top: Constants.Size.ItemHeightMid, left: 0, bottom: bottomInset, right: 0)
return view
}()
@@ -99,11 +103,13 @@ class WebViewController: BaseViewController {
private var loadUrlWhenInit: Bool
+ private var bottomInset: CGFloat? = nil
+
deinit {
webView.navigationDelegate = nil
}
- init(url: URL = URL(string: Constants.URLs.ManicEMU)!, showClose: Bool = true, isShow: Bool? = nil) {
+ init(url: URL = URL(string: Constants.URLs.ManicEMU)!, showClose: Bool = true, isShow: Bool? = nil, bottomInset: CGFloat? = nil) {
self.url = url
self.showClose = showClose
self.loadUrlWhenInit = true
@@ -111,6 +117,7 @@ class WebViewController: BaseViewController {
Self.isShow = isShow
}
super.init(nibName: nil, bundle: nil)
+ self.bottomInset = bottomInset
}
init(searchGame: Game) {
diff --git a/ManicEmu/ManicEmu/Sources/Business/Controllers/Views/ControllersSettingView.swift b/ManicEmu/ManicEmu/Sources/Business/Controllers/Views/ControllersSettingView.swift
index 30d22b6f..c996bc94 100644
--- a/ManicEmu/ManicEmu/Sources/Business/Controllers/Views/ControllersSettingView.swift
+++ b/ManicEmu/ManicEmu/Sources/Business/Controllers/Views/ControllersSettingView.swift
@@ -283,12 +283,12 @@ extension ControllersSettingView {
Sheet.find(identifier: String(describing: ControllersSettingView.self)).count > 0 ? true : false
}
- static func show(gameType: GameType, gameViewRect: CGRect, hideCompletion: (()->Void)? = nil, didTapClose: (()->Void)? = nil) {
+ static func show(gameType: GameType, gameViewRect: CGRect, menuInsets: UIEdgeInsets? = nil, hideCompletion: (()->Void)? = nil, didTapClose: (()->Void)? = nil) {
Sheet.lazyPush(identifier: String(describing: ControllersSettingView.self)) { sheet in
- sheet.configGamePlayingStyle(gameViewRect: gameViewRect, hideCompletion: hideCompletion)
+ sheet.configGamePlayingStyle(gameViewRect: gameViewRect, menuInsets: menuInsets, hideCompletion: hideCompletion)
let view = UIView()
- let containerView = RoundAndBorderView(roundCorner: (UIDevice.isPad || UIDevice.isLandscape) ? .allCorners : [.topLeft, .topRight])
+ let containerView = RoundAndBorderView(roundCorner: (UIDevice.isPad || UIDevice.isLandscape || menuInsets != nil) ? .allCorners : [.topLeft, .topRight])
containerView.backgroundColor = Constants.Color.BackgroundPrimary
view.addSubview(containerView)
containerView.snp.makeConstraints { make in
diff --git a/ManicEmu/ManicEmu/Sources/Business/Filter/Views/FilterSelectionView.swift b/ManicEmu/ManicEmu/Sources/Business/Filter/Views/FilterSelectionView.swift
index 8de5d008..cf12ffca 100644
--- a/ManicEmu/ManicEmu/Sources/Business/Filter/Views/FilterSelectionView.swift
+++ b/ManicEmu/ManicEmu/Sources/Business/Filter/Views/FilterSelectionView.swift
@@ -292,12 +292,12 @@ extension FilterSelectionView {
Sheet.find(identifier: String(describing: FilterSelectionView.self)).count > 0 ? true : false
}
- static func show(game: Game, snapshot: UIImage?, gameViewRect: CGRect, hideCompletion: (()->Void)? = nil, didTapClose: (()->Void)? = nil) {
+ static func show(game: Game, snapshot: UIImage?, gameViewRect: CGRect, menuInsets: UIEdgeInsets? = nil, hideCompletion: (()->Void)? = nil, didTapClose: (()->Void)? = nil) {
Sheet.lazyPush(identifier: String(describing: FilterSelectionView.self)) { sheet in
- sheet.configGamePlayingStyle(gameViewRect: gameViewRect, hideCompletion: hideCompletion)
+ sheet.configGamePlayingStyle(gameViewRect: gameViewRect, menuInsets: menuInsets, hideCompletion: hideCompletion)
let view = UIView()
- let containerView = RoundAndBorderView(roundCorner: (UIDevice.isPad || UIDevice.isLandscape) ? .allCorners : [.topLeft, .topRight])
+ let containerView = RoundAndBorderView(roundCorner: (UIDevice.isPad || UIDevice.isLandscape || menuInsets != nil) ? .allCorners : [.topLeft, .topRight])
containerView.backgroundColor = Constants.Color.BackgroundPrimary
view.addSubview(containerView)
containerView.snp.makeConstraints { make in
diff --git a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameInfoView.swift b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameInfoView.swift
index 26757f47..14e40634 100644
--- a/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameInfoView.swift
+++ b/ManicEmu/ManicEmu/Sources/Business/GameInfo/VIews/GameInfoView.swift
@@ -561,12 +561,12 @@ extension GameInfoView {
Sheet.find(identifier: String(describing: GameInfoView.self)).count > 0 ? true : false
}
- static func show(game: Game, gameViewRect: CGRect, selection: ((GameSaveState)->Void)? = nil, hideCompletion: (()->Void)? = nil, didTapClose: (()->Void)? = nil) {
+ static func show(game: Game, gameViewRect: CGRect, menuInsets: UIEdgeInsets? = nil, selection: ((GameSaveState)->Void)? = nil, hideCompletion: (()->Void)? = nil, didTapClose: (()->Void)? = nil) {
Sheet.lazyPush(identifier: String(describing: GameInfoView.self)) { sheet in
- sheet.configGamePlayingStyle(gameViewRect: gameViewRect, hideCompletion: hideCompletion)
+ sheet.configGamePlayingStyle(gameViewRect: gameViewRect, menuInsets: menuInsets, hideCompletion: hideCompletion)
let view = UIView()
- let containerView = RoundAndBorderView(roundCorner: (UIDevice.isPad || UIDevice.isLandscape) ? .allCorners : [.topLeft, .topRight])
+ let containerView = RoundAndBorderView(roundCorner: (UIDevice.isPad || UIDevice.isLandscape || menuInsets != nil) ? .allCorners : [.topLeft, .topRight])
containerView.backgroundColor = Constants.Color.BackgroundPrimary
view.addSubview(containerView)
containerView.snp.makeConstraints { make in
diff --git a/ManicEmu/ManicEmu/Sources/Business/Play/VIewControllers/PlayViewController.swift b/ManicEmu/ManicEmu/Sources/Business/Play/VIewControllers/PlayViewController.swift
index a3af5ffb..c5a71b9c 100644
--- a/ManicEmu/ManicEmu/Sources/Business/Play/VIewControllers/PlayViewController.swift
+++ b/ManicEmu/ManicEmu/Sources/Business/Play/VIewControllers/PlayViewController.swift
@@ -736,6 +736,7 @@ class PlayViewController: GameViewController {
}
GameSettingView.show(game: manicGame,
gameViewRect: gameView.frame,
+ menuInsets: getMenuInset(),
didSelectItem: { [weak self] item, sheet in
//点击菜单选项
guard let self = self else { return true }
@@ -1278,7 +1279,7 @@ extension PlayViewController {
if menuSheet == nil {
pauseEmulation()
}
- GameInfoView.show(game: manicGame, gameViewRect: gameView.frame, selection: { [weak self, weak menuSheet] saveState in
+ GameInfoView.show(game: manicGame, gameViewRect: gameView.frame, menuInsets: getMenuInset(), selection: { [weak self, weak menuSheet] saveState in
guard let self = self else { return }
func loadSave() {
if self.manicGame.gameType == ._3ds {
@@ -1325,7 +1326,7 @@ extension PlayViewController {
if menuSheet == nil {
pauseEmulation()
}
- CheatCodeListView.show(game: manicGame, gameViewRect: gameView.frame, hideCompletion: { [weak self] in
+ CheatCodeListView.show(game: manicGame, gameViewRect: gameView.frame, menuInsets: getMenuInset(), hideCompletion: { [weak self] in
if menuSheet == nil {
self?.resumeEmulationAndHandleAudio()
}
@@ -1336,7 +1337,7 @@ extension PlayViewController {
if menuSheet == nil {
pauseEmulation()
}
- SkinSettingsView.show(game: manicGame, gameViewRect: gameView.frame, hideCompletion: { [weak self] in
+ SkinSettingsView.show(game: manicGame, gameViewRect: gameView.frame, menuInsets: getMenuInset(), hideCompletion: { [weak self] in
if menuSheet == nil {
self?.resumeEmulationAndHandleAudio()
}
@@ -1348,7 +1349,7 @@ extension PlayViewController {
pauseEmulation()
}
if manicGame.gameType.isLibretroType {
- FilterSelectionView.show(game: self.manicGame, snapshot: nil, gameViewRect: self.gameView.frame, hideCompletion: { [weak self] in
+ FilterSelectionView.show(game: self.manicGame, snapshot: nil, gameViewRect: self.gameView.frame, menuInsets: getMenuInset(), hideCompletion: { [weak self] in
if menuSheet == nil {
self?.resumeEmulationAndHandleAudio()
}
@@ -1358,7 +1359,7 @@ extension PlayViewController {
if manicGame.gameType == .ds, let temp = snapshot {
snapshot = temp.cropped(to: CGRect(origin: .zero, size: CGSize(width: temp.size.width, height: temp.size.height/2)))
}
- FilterSelectionView.show(game: manicGame, snapshot: snapshot, gameViewRect: gameView.frame, hideCompletion: { [weak self] in
+ FilterSelectionView.show(game: manicGame, snapshot: snapshot, gameViewRect: gameView.frame, menuInsets: getMenuInset(), hideCompletion: { [weak self] in
if menuSheet == nil {
self?.resumeEmulationAndHandleAudio()
}
@@ -1419,7 +1420,7 @@ extension PlayViewController {
if menuSheet == nil {
pauseEmulation()
}
- let vc = WebViewController(url: Constants.URLs.AirPlayUsageGuide, isShow: true)
+ let vc = WebViewController(url: Constants.URLs.AirPlayUsageGuide, isShow: true, bottomInset: getMenuInset()?.bottom ?? nil)
vc.didClose = { [weak self] in
if menuSheet == nil {
self?.resumeEmulationAndHandleAudio()
@@ -1431,7 +1432,7 @@ extension PlayViewController {
if menuSheet == nil {
pauseEmulation()
}
- ControllersSettingView.show(gameType: manicGame.gameType, gameViewRect: gameView.frame, hideCompletion: { [weak self] in
+ ControllersSettingView.show(gameType: manicGame.gameType, gameViewRect: gameView.frame, menuInsets: getMenuInset(), hideCompletion: { [weak self] in
if menuSheet == nil {
self?.resumeEmulationAndHandleAudio()
}
@@ -1454,7 +1455,7 @@ extension PlayViewController {
if menuSheet == nil {
pauseEmulation()
}
- GameSettingView.show(game: manicGame, gameViewRect: gameView.frame, isEditingMode: true, hideCompletion: { [weak self] in
+ GameSettingView.show(game: manicGame, gameViewRect: gameView.frame, isEditingMode: true, menuInsets: getMenuInset(), hideCompletion: { [weak self] in
if menuSheet == nil {
self?.resumeEmulationAndHandleAudio()
}
@@ -1599,7 +1600,7 @@ extension PlayViewController {
pauseEmulation()
}
func openRetroAchievementsList() {
- let vc = RetroAchievementsListViewController(game: manicGame)
+ let vc = RetroAchievementsListViewController(game: manicGame, bottomInset: getMenuInset()?.bottom ?? nil)
vc.didClose = { [weak self] in
if menuSheet == nil {
self?.resumeEmulationAndHandleAudio()
@@ -2671,6 +2672,24 @@ extension PlayViewController {
self.leaderboardView = leaderboardView
}
}
+
+ private func getMenuInset() -> UIEdgeInsets? {
+ var menuInsets: UIEdgeInsets? = nil
+ if let traits = controllerView.controllerSkinTraits, let insets = controllerView.controllerSkin?.menuInsets(for: traits) {
+ func absoluteValue(for inset: Double, dimension: Double) -> Double {
+ guard inset > 0 && inset <= 1.0 else { return inset }
+ let absoluteValue = inset * dimension
+ return absoluteValue
+ }
+ var absoluteMenuInsets = UIEdgeInsets.zero
+ absoluteMenuInsets.left = absoluteValue(for: insets.left, dimension: self.view.bounds.width)
+ absoluteMenuInsets.right = absoluteValue(for: insets.right, dimension: self.view.bounds.width)
+ absoluteMenuInsets.top = absoluteValue(for: insets.top, dimension: self.view.bounds.height)
+ absoluteMenuInsets.bottom = absoluteValue(for: insets.bottom, dimension: self.view.bounds.height)
+ menuInsets = absoluteMenuInsets
+ }
+ return menuInsets
+ }
}
//MARK: GameViewControllerDelegate代理
diff --git a/ManicEmu/ManicEmu/Sources/Business/Play/Views/GameSettingView.swift b/ManicEmu/ManicEmu/Sources/Business/Play/Views/GameSettingView.swift
index 82690a58..3b10e702 100644
--- a/ManicEmu/ManicEmu/Sources/Business/Play/Views/GameSettingView.swift
+++ b/ManicEmu/ManicEmu/Sources/Business/Play/Views/GameSettingView.swift
@@ -688,11 +688,12 @@ extension GameSettingView {
static func show(game: Game,
gameViewRect: CGRect,
isEditingMode: Bool = false,
+ menuInsets: UIEdgeInsets? = nil,
didSelectItem:((_ item: GameSetting, _ sheet: SheetTarget?)->Bool)? = nil,
hideCompletion: (()->Void)? = nil) {
let initializer: ((SheetTarget)->Void) = { sheet in
- sheet.configGamePlayingStyle(isForGameMenu: isEditingMode ? false : true, gameViewRect: gameViewRect, hideCompletion: hideCompletion)
+ sheet.configGamePlayingStyle(isForGameMenu: isEditingMode ? false : true, gameViewRect: gameViewRect, menuInsets: menuInsets, hideCompletion: hideCompletion)
let view = UIView()
let grabber = UIImageView(image: R.image.grabber_icon())
@@ -723,7 +724,7 @@ extension GameSettingView {
}
- let containerView = RoundAndBorderView(roundCorner: (UIDevice.isPad || UIDevice.isLandscape) ? .allCorners : [.topLeft, .topRight])
+ let containerView = RoundAndBorderView(roundCorner: (UIDevice.isPad || UIDevice.isLandscape || menuInsets != nil) ? .allCorners : [.topLeft, .topRight])
containerView.backgroundColor = Constants.Color.BackgroundPrimary
if !isEditingMode {
containerView.makeBlur()
diff --git a/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/ViewControllers/RetroAchievementsListViewController.swift b/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/ViewControllers/RetroAchievementsListViewController.swift
index 828e0d34..53dc1697 100644
--- a/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/ViewControllers/RetroAchievementsListViewController.swift
+++ b/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/ViewControllers/RetroAchievementsListViewController.swift
@@ -17,7 +17,7 @@ class RetroAchievementsListViewController: BaseViewController {
}()
private lazy var listView: RetroAchievementListView = {
- let view = RetroAchievementListView(game: self.game)
+ let view = RetroAchievementListView(game: self.game, bottomInset: self.bottomInset)
return view
}()
@@ -27,15 +27,18 @@ class RetroAchievementsListViewController: BaseViewController {
private let game: Game
+ private var bottomInset: CGFloat? = nil
+
deinit {
if let quitGamingNotification {
NotificationCenter.default.removeObserver(quitGamingNotification)
}
}
- init(game: Game) {
+ init(game: Game, bottomInset: CGFloat? = nil) {
self.game = game
super.init(nibName: nil, bundle: nil)
+ self.bottomInset = bottomInset
}
@MainActor required init?(coder: NSCoder) {
diff --git a/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/Views/RetroAchievementListView.swift b/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/Views/RetroAchievementListView.swift
index 29de5884..732f2d8e 100644
--- a/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/Views/RetroAchievementListView.swift
+++ b/ManicEmu/ManicEmu/Sources/Business/RetroAchievements/Views/RetroAchievementListView.swift
@@ -15,7 +15,11 @@ class RetroAchievementListView: BaseView {
view.register(cellWithClass: RetroAchievementsListCell.self)
view.showsVerticalScrollIndicator = false
view.dataSource = self
- view.contentInset = UIEdgeInsets(top: 90, left: 0, bottom: Constants.Size.ContentInsetBottom, right: 0)
+ var bottomInset = Constants.Size.ContentInsetBottom
+ if let prefferdBottomInset = self.bottomInset, bottomInset < prefferdBottomInset {
+ bottomInset = prefferdBottomInset
+ }
+ view.contentInset = UIEdgeInsets(top: 90, left: 0, bottom: bottomInset, right: 0)
let blankView = BlankSlateEmptyView(image: .symbolImage(.gamecontrollerFill).applySymbolConfig(size: 70, color: Constants.Color.LabelSecondary), title: R.string.localizable.achievementsNotSupport(game.aliasName ?? game.name))
blankView.label.isHidden = true
view.blankSlateView = blankView
@@ -25,10 +29,12 @@ class RetroAchievementListView: BaseView {
private var game: Game
private var cheevosGame: CheevosGame? = nil
+ private var bottomInset: CGFloat? = nil
- init(game: Game) {
+ init(game: Game, bottomInset: CGFloat? = nil) {
self.game = game
super.init(frame: .zero)
+ self.bottomInset = bottomInset
backgroundColor = .clear
addSubview(collectionView)
diff --git a/ManicEmu/ManicEmu/Sources/Business/Skin/Views/SkinSettingsView.swift b/ManicEmu/ManicEmu/Sources/Business/Skin/Views/SkinSettingsView.swift
index a8bef939..32d487d6 100644
--- a/ManicEmu/ManicEmu/Sources/Business/Skin/Views/SkinSettingsView.swift
+++ b/ManicEmu/ManicEmu/Sources/Business/Skin/Views/SkinSettingsView.swift
@@ -611,12 +611,12 @@ extension SkinSettingsView {
Sheet.find(identifier: String(describing: SkinSettingsView.self)).count > 0 ? true : false
}
- static func show(game: Game, gameViewRect: CGRect, hideCompletion: (()->Void)? = nil, didTapClose: (()->Void)? = nil) {
+ static func show(game: Game, gameViewRect: CGRect, menuInsets: UIEdgeInsets? = nil, hideCompletion: (()->Void)? = nil, didTapClose: (()->Void)? = nil) {
Sheet.lazyPush(identifier: String(describing: SkinSettingsView.self)) { sheet in
- sheet.configGamePlayingStyle(gameViewRect: gameViewRect, hideCompletion: hideCompletion)
+ sheet.configGamePlayingStyle(gameViewRect: gameViewRect, menuInsets: menuInsets, hideCompletion: hideCompletion)
let view = UIView()
- let containerView = RoundAndBorderView(roundCorner: (UIDevice.isPad || UIDevice.isLandscape) ? .allCorners : [.topLeft, .topRight])
+ let containerView = RoundAndBorderView(roundCorner: (UIDevice.isPad || UIDevice.isLandscape || menuInsets != nil) ? .allCorners : [.topLeft, .topRight])
containerView.backgroundColor = Constants.Color.BackgroundPrimary
view.addSubview(containerView)
containerView.snp.makeConstraints { make in
diff --git a/ManicEmu/ManicEmu/Sources/Tools/Extensions/SheerExtensions.swift b/ManicEmu/ManicEmu/Sources/Tools/Extensions/SheerExtensions.swift
index 9b7d466e..ddc47d9e 100644
--- a/ManicEmu/ManicEmu/Sources/Tools/Extensions/SheerExtensions.swift
+++ b/ManicEmu/ManicEmu/Sources/Tools/Extensions/SheerExtensions.swift
@@ -11,7 +11,7 @@ import ProHUD
extension SheetTarget {
- func configGamePlayingStyle(isForGameMenu: Bool = false, gameViewRect:CGRect, hideCompletion: (()->Void)? = nil) {
+ func configGamePlayingStyle(isForGameMenu: Bool = false, gameViewRect:CGRect, menuInsets: UIEdgeInsets? = nil, hideCompletion: (()->Void)? = nil) {
//设置点击背景的回调
self.onTappedBackground { sheet in
sheet.pop(completon: hideCompletion)
@@ -52,5 +52,33 @@ extension SheetTarget {
}
self.config.cardMaxWidth = sheetSize.width
self.config.cardMaxHeight = sheetSize.height
+
+
+ if let menuInsets {
+ //设置了菜单的边距
+ var prefferdHeight = Constants.Size.WindowHeight - menuInsets.top - menuInsets.bottom
+
+ if UIDevice.isPhone, !UIDevice.isLandscape {
+ prefferdHeight -= Constants.Size.ContentInsetTop
+ }
+
+ if prefferdHeight < self.config.cardMaxHeight! {
+ self.config.cardMaxHeight = prefferdHeight
+ }
+
+ var prefferdWidth = Constants.Size.WindowWidth - menuInsets.left - menuInsets.right
+
+ if UIDevice.isPhone, UIDevice.isLandscape {
+ prefferdWidth = prefferdWidth - Constants.Size.SafeAera.left - Constants.Size.SafeAera.right
+ }
+
+ if prefferdWidth < self.config.cardMaxWidth! {
+ self.config.cardMaxWidth = prefferdWidth
+ }
+
+ if menuInsets.bottom > 0 {
+ self.config.bottomEdgeInset = menuInsets.bottom
+ }
+ }
}
}
diff --git a/ManicEmu/Podfile b/ManicEmu/Podfile
index 877bbca6..ace56039 100644
--- a/ManicEmu/Podfile
+++ b/ManicEmu/Podfile
@@ -41,7 +41,7 @@ target 'ManicEmu' do
pod 'SideMenu', '~> 6.5'
pod 'VisualEffectView', '~> 5.0'
pod 'FluentDarkModeKit', '~> 1.0.4'
- pod "Device", '~> 3.7'
+ pod "Device", :git => 'https://github.com/LeeAoshuang/Device.git', :branch => 'master'
pod 'SFSafeSymbols', '~> 5.0'
pod "Haptica", '~> 3.0'
pod 'IQKeyboardManagerSwift', '~> 8.0'
diff --git a/ManicEmu/Podfile.lock b/ManicEmu/Podfile.lock
index 948c96ca..6ef0c021 100644
--- a/ManicEmu/Podfile.lock
+++ b/ManicEmu/Podfile.lock
@@ -194,7 +194,7 @@ DEPENDENCIES:
- Closures (from `../Closures/Xcode/Closures`)
- CloudServiceKit (from `../CloudServiceKit`)
- CollectionViewPagingLayout (from `../CollectionViewPagingLayout`)
- - Device (~> 3.7)
+ - Device (from `https://github.com/LeeAoshuang/Device.git`, branch `master`)
- DNSPageView (from `../DNSPageView`)
- Fireworks (from `https://github.com/tomkowz/fireworks.git`, branch `master`)
- FLEX
@@ -238,7 +238,6 @@ DEPENDENCIES:
SPEC REPOS:
trunk:
- BetterSegmentedControl
- - Device
- FLEX
- FluentDarkModeKit
- Fuse
@@ -282,6 +281,9 @@ EXTERNAL SOURCES:
:path: "../CloudServiceKit"
CollectionViewPagingLayout:
:path: "../CollectionViewPagingLayout"
+ Device:
+ :branch: master
+ :git: https://github.com/LeeAoshuang/Device.git
DNSPageView:
:path: "../DNSPageView"
Fireworks:
@@ -317,6 +319,9 @@ EXTERNAL SOURCES:
:path: "../ZIPFoundation"
CHECKOUT OPTIONS:
+ Device:
+ :commit: 7ff1e9987d8348f59cdf756ef515ca5a1ce13f91
+ :git: https://github.com/LeeAoshuang/Device.git
Fireworks:
:commit: c54a983649510ddaf1ff315000626eb43486410b
:git: https://github.com/tomkowz/fireworks.git
@@ -378,6 +383,6 @@ SPEC CHECKSUMS:
VisualEffectView: 173e1fabc2eb37af663547e14dc12efef7d2da8b
ZIPFoundation: b8c29ea7ae353b309bc810586181fd073cb3312c
-PODFILE CHECKSUM: cc4c8f981e09ce8534f6ff56af8841770c085798
+PODFILE CHECKSUM: c6716083ae00e5f7023f75cbece2ea336910aced
COCOAPODS: 1.16.2
diff --git a/ProHUD/Sources/ProHUD/Sheet/SheetConfiguration.swift b/ProHUD/Sources/ProHUD/Sheet/SheetConfiguration.swift
index 260ad44a..979c815b 100644
--- a/ProHUD/Sources/ProHUD/Sheet/SheetConfiguration.swift
+++ b/ProHUD/Sources/ProHUD/Sheet/SheetConfiguration.swift
@@ -15,6 +15,9 @@ public class SheetConfiguration: CommonConfiguration {
/// 卡片距离屏幕的间距
public var windowEdgeInset: CGFloat = 16
+ /// 卡片距离屏幕的底部距离
+ public var bottomEdgeInset: CGFloat? = nil
+
/// 是否是全屏的页面
public var isFullScreen = false
diff --git a/ProHUD/Sources/ProHUD/Sheet/SheetDefaultLayout.swift b/ProHUD/Sources/ProHUD/Sheet/SheetDefaultLayout.swift
index 4ebd73ac..634b5432 100644
--- a/ProHUD/Sources/ProHUD/Sheet/SheetDefaultLayout.swift
+++ b/ProHUD/Sources/ProHUD/Sheet/SheetDefaultLayout.swift
@@ -57,10 +57,14 @@ extension SheetTarget: DefaultLayout {
// iPad且窗口宽度较宽时居中弹出
make.centerY.equalToSuperview()
} else {
- if isPortrait {
- make.bottom.equalToSuperview().inset(config.windowEdgeInset)
+ if let bottomEdgeInset = config.bottomEdgeInset {
+ make.bottom.equalToSuperview().inset(bottomEdgeInset)
} else {
- make.bottom.equalToSuperview().inset(AppContext.safeAreaInsets.bottom)
+ if isPortrait {
+ make.bottom.equalToSuperview().inset(config.windowEdgeInset)
+ } else {
+ make.bottom.equalToSuperview().inset(AppContext.safeAreaInsets.bottom)
+ }
}
}
make.width.equalTo(width)