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
Add enable carousel styles option for landscape mode; optimize the carousel paging experience;
Daiuno67e87d9ea3b6
diff --git a/ManicEmu/ManicEmu/Resources/en.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/en.lproj/Localizable.stringsindex 62e3e288..e2b16432 100644--- a/ManicEmu/ManicEmu/Resources/en.lproj/Localizable.strings+++ b/ManicEmu/ManicEmu/Resources/en.lproj/Localizable.strings@@ -1154,3 +1154,5 @@ Press the controller button to complete mapping...";"ResetTips" = "Reset Tips";"ResetTipsDesc" = "Show previously dismissed alerts and tips again";"ResetTipsSuccess" = "Tips reset successfully";++"EnableCarouselStyle" = "Enable Carousel Style";diff --git a/ManicEmu/ManicEmu/Resources/zh-Hans.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/zh-Hans.lproj/Localizable.stringsindex db5f3c47..bdb7658a 100644--- a/ManicEmu/ManicEmu/Resources/zh-Hans.lproj/Localizable.strings+++ b/ManicEmu/ManicEmu/Resources/zh-Hans.lproj/Localizable.strings@@ -1149,3 +1149,5 @@"ResetTips" = "重置提示";"ResetTipsDesc" = "让已展示过的弹窗和提示再次出现";"ResetTipsSuccess" = "提示重置成功";++"EnableCarouselStyle" = "启用轮播样式";diff --git a/ManicEmu/ManicEmu/Sources/Business/Common/Models/ExtraKey.swift b/ManicEmu/ManicEmu/Sources/Business/Common/Models/ExtraKey.swiftindex 7e281740..466579b2 100644--- a/ManicEmu/ManicEmu/Sources/Business/Common/Models/ExtraKey.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Common/Models/ExtraKey.swift@@ -70,6 +70,7 @@ enum ExtraKey: String {case gamehackingBookMarkcase steamGridDBAPIKeycase landscapeListStyle+ case landscapeCarouselEnabledcase landscapeShaderToycase landscapeBackgroundMusiccase landscapeSoundEffectsdiff --git a/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameLandscapeCarouselCell.swift b/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameLandscapeCarouselCell.swiftindex fee74b40..ff2c409b 100644--- a/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameLandscapeCarouselCell.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameLandscapeCarouselCell.swift@@ -12,7 +12,7 @@ import CollectionViewPagingLayoutenum LandscapeCarouselStyle: Int, CaseIterable {case scale, stack, snapshot- ///当前生效的样式族 持久化在Theme extras中 默认Scale+ /// Active style family, persisted in Theme extras. Default Scale.static var current: LandscapeCarouselStyle {get {LandscapeCarouselStyle(rawValue: Theme.defalut.getExtraInt(key: ExtraKey.landscapeListStyle.rawValue) ?? 0) ?? .scale@@ -22,6 +22,12 @@ enum LandscapeCarouselStyle: Int, CaseIterable {}}+ /// Cover-flow carousel when true (default). Sectioned list rows when false.+ static var isCarouselEnabled: Bool {+ get { Theme.defalut.getExtraBool(key: ExtraKey.landscapeCarouselEnabled.rawValue) ?? true }+ set { Theme.defalut.updateExtra(key: ExtraKey.landscapeCarouselEnabled.rawValue, value: newValue) }+ }+var title: String {switch self {case .scale: return "Scale"diff --git a/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameListLandscapeView.swift b/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameListLandscapeView.swiftindex 7b42ed85..f01a8962 100644--- a/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameListLandscapeView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Games/Views/GameListLandscapeView.swift@@ -97,7 +97,10 @@ class GameListLandscapeView: BaseView {private lazy var carouselView: UICollectionView = {let view = UICollectionView(frame: .zero, collectionViewLayout: carouselLayout)view.backgroundColor = .clear- view.isPagingEnabled = LandscapeCarouselStyle.current.usesSystemPaging+ view.isPagingEnabled = false+ view.decelerationRate = Self.carouselDecelerationRate+ view.alwaysBounceHorizontal = true+ view.delaysContentTouches = falseview.showsHorizontalScrollIndicator = falseview.clipsToBounds = falseview.contentInsetAdjustmentBehavior = .never@@ -106,6 +109,35 @@ class GameListLandscapeView: BaseView {view.register(cellWithClass: GameLandscapeSnapshotCell.self)view.dataSource = selfview.delegate = self+ view.isHidden = !LandscapeCarouselStyle.isCarouselEnabled+ return view+ }()++ /// GameList-style sectioned rows used when carousel is turned off.+ private lazy var listView: UICollectionView = {+ let view = UICollectionView(frame: .zero, collectionViewLayout: createListLayout())+ view.backgroundColor = .clear+ view.contentInsetAdjustmentBehavior = .never+ view.register(cellWithClass: GameCollectionViewCell.self)+ view.register(supplementaryViewOfKind: UICollectionView.elementKindSectionHeader, withClass: GamesCollectionReusableView.self)+ view.showsVerticalScrollIndicator = false+ view.showsHorizontalScrollIndicator = false+ view.dataSource = self+ 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+ view.contentInset = .insets(bottom: bottom)+ view.isHidden = LandscapeCarouselStyle.isCarouselEnabled+ view.addLongPressGesture(handler: { [weak self] gesture in+ guard gesture.state == .began,+ let self,+ !self.isCarouselEnabled,+ let indexPath = self.listView.indexPathForItem(at: gesture.location(in: self.listView)),+ let game = self.listGame(at: indexPath) else { return }+ UIDevice.generateHaptic(style: .heavy)+ self.showListGameEditSheet(game: game)+ }).delegate = selfreturn view}()@@ -196,12 +228,18 @@ class GameListLandscapeView: BaseView {private(set) var selectedGameType: GameType? = nil///当前厂商下可筛选的游戏类型private var availableGameTypes: [GameType] = []- ///content区展示的游戏+ /// Flattened games for the carousel.private var displayGames: [Game] = []- ///搜索关键字+ /// One horizontal row per GameType for the sectioned list.+ private var displaySections: [(gameType: GameType, games: [Game])] = []+ private var listCoverSizes = [GameType: CGSize]()+ /// Search keywordprivate var searchString: String? = nil+ private var isCarouselEnabled: Bool { LandscapeCarouselStyle.isCarouselEnabled }+private var focusedGame: Game? {+ guard isCarouselEnabled else { return nil }let index = carouselLayout.currentPageguard index >= 0, index < displayGames.count else { return nil }return displayGames[index]@@ -210,16 +248,13 @@ class GameListLandscapeView: BaseView {private var lastLayoutSize: CGSize = .zero/// Last info-panel anchor; skip constraint updates when unchanged.private var lastPanelAnchor: CGPoint = .zero- /// Scale/Stack flick in progress; focus info waits until the snap finishes.- private var isCarouselUserScrolling = false- private var isCarouselSnapping = false+ /// Destination page whose background is committed while a flick settles.+ private var settlingBackgroundPage: Int?+ /// Skip posting the same background again so the 0.35s fade does not restart.+ private var appliedCarouselBackground: AppliedCarouselBackground?private var notificationTokens = [Any]()- private var usesSystemCarouselPaging: Bool {- LandscapeCarouselStyle.current.usesSystemPaging- }-//MARK: - 生命周期override init(frame: CGRect) {super.init(frame: frame)@@ -244,6 +279,8 @@ class GameListLandscapeView: BaseView {BackgroundMusicKit.shared.setLandscapeHomeVisible(false)carouselView.dataSource = nilcarouselView.delegate = nil+ listView.dataSource = nil+ listView.delegate = nil}override func layoutSubviews() {@@ -251,10 +288,16 @@ class GameListLandscapeView: BaseView {guard window != nil, superview != nil else { return }if bounds.size != lastLayoutSize, bounds.size != .zero {lastLayoutSize = bounds.size- //尺寸变化时轮播cell的封面尺寸需要重新计算- carouselView.reloadData()+ if isCarouselEnabled {+ carouselView.reloadData()+ } else {+ listView.collectionViewLayout.invalidateLayout()+ listView.reloadData()+ }+ }+ if isCarouselEnabled {+ updateInfoPanelPosition()}- updateInfoPanelPosition()}@@ -295,7 +338,12 @@ class GameListLandscapeView: BaseView {make.height.equalTo(R.Size.ButtonSmall)}- //content区轮播 置于最底层+ // Content sits behind navigation. List is inserted first so carousel stays on top when both exist.+ insertSubview(listView, at: 0)+ listView.snp.makeConstraints { make in+ make.leading.bottom.trailing.equalToSuperview()+ make.top.equalTo(navigationView.snp.bottom)+ }insertSubview(carouselView, at: 0)carouselView.snp.makeConstraints { make inmake.leading.trailing.equalToSuperview()@@ -318,7 +366,7 @@ class GameListLandscapeView: BaseView {make.width.lessThanOrEqualToSuperview().offset(-R.Size.ContentSpaceLarge*2)}- applyCarouselPagingMode()+ applyContentMode()}private func setupDatas() {@@ -355,7 +403,9 @@ class GameListLandscapeView: BaseView {R.NotificationName.GameCategoryChange,R.NotificationName.PlatformOrderChange,R.NotificationName.PlatformSelectionChange,- R.NotificationName.GameCoverChange+ R.NotificationName.GameCoverChange,+ R.NotificationName.GameListStyleChange,+ R.NotificationName.HideGameRating]for name in reloadNames {notificationTokens.append(center.addObserver(forName: name, object: nil, queue: .main) { [weak self] _ in@@ -375,9 +425,12 @@ class GameListLandscapeView: BaseView {notificationTokens.append(center.addObserver(forName: R.NotificationName.GameMetadataChange, object: nil, queue: .main) { [weak self] notification inguard let self = self, !R.Style.GameHideRating else { return }- if let gameId = notification.object as? String,+ guard let gameId = notification.object as? String else { return }+ if self.isCarouselEnabled,let row = self.displayGames.firstIndex(where: { $0.id == gameId }) {self.carouselView.reloadItems(at: [IndexPath(row: row, section: 0)])+ } else if let indexPath = self.listIndexPath(for: gameId) {+ self.listView.reloadItems(at: [indexPath])}})@@ -486,64 +539,74 @@ class GameListLandscapeView: BaseView {}}- ///重建数据源 厂商→gameType→扁平游戏数组+ /// Rebuild manufacturer → gameType groups, then both the carousel list and sectioned rows.private func rebuildDatas() {- //按虚拟类型分组var grouped: [GameType: [Game]] = [:]for game in games {grouped[game.effectiveGameType, default: []].append(game)}- //平台可见性过滤for type in Array(grouped.keys) where !Self.isPlatformVisible(type) {grouped[type] = nil}- //厂商过滤if let manufacturer = selectedManufacturer {grouped = grouped.filter { Self.manufacturerAllows($0.key, manufacturer: manufacturer) }}availableGameTypes = Self.predefinedGameTypeOrder().filter { grouped.keys.contains($0) }- //类型筛选失效时重置if let selectedGameType, !availableGameTypes.contains(selectedGameType) {self.selectedGameType = nil}- //扁平化 保持组内排序与组间顺序- var list: [Game]+ func matchesSearch(_ game: Game) -> Bool {+ guard let searchString, !searchString.isEmpty else { return true }+ return (game.displayName + game.fileExtension).contains(searchString, caseSensitive: false)+ }++ let sectionTypes: [GameType]if let selectedGameType {- list = sortGames(grouped[selectedGameType] ?? [])+ sectionTypes = [selectedGameType]} else {- list = availableGameTypes.flatMap { sortGames(grouped[$0] ?? []) }+ sectionTypes = availableGameTypes}- //搜索过滤- if let searchString, !searchString.isEmpty {- list = list.filter { ($0.displayName + $0.fileExtension).contains(searchString, caseSensitive: false) }+ displaySections = sectionTypes.compactMap { type in+ let games = sortGames(grouped[type] ?? []).filter(matchesSearch)+ return games.isEmpty ? nil : (type, games)}-- displayGames = list+ displayGames = displaySections.flatMap { $0.games }}private func reloadAll(keepFocus: Bool) {- let focusId = keepFocus ? focusedGame?.id : nil+ let focusId = keepFocus && isCarouselEnabled ? focusedGame?.id : nilrebuildDatas()- applyCarouselPagingMode()- carouselLayout.invalidateLayoutInBatchUpdate()- carouselView.reloadData()+ applyContentMode()- if let focusId, let index = displayGames.firstIndex(where: { $0.id == focusId }) {- carouselLayout.setCurrentPage(index, animated: false)- } else if carouselView.numberOfItems(inSection: 0) > 0 {- carouselLayout.setCurrentPage(0, animated: false)- }- updateFocusedGameInfo()- // Cell frames are ready on the next cycle; snap the info panel then.- DispatchQueue.main.async { [weak self] in- self?.updateInfoPanelPosition()- self?.syncCarouselFocusTargets()+ settlingBackgroundPage = nil+ appliedCarouselBackground = nil++ if isCarouselEnabled {+ applyCarouselPagingMode()+ carouselLayout.invalidateLayoutInBatchUpdate()+ carouselView.reloadData()++ if let focusId, let index = displayGames.firstIndex(where: { $0.id == focusId }) {+ carouselLayout.setCurrentPage(index, animated: false)+ } else if carouselView.numberOfItems(inSection: 0) > 0 {+ carouselLayout.setCurrentPage(0, animated: false)+ }+ updateFocusedGameInfo()+ DispatchQueue.main.async { [weak self] in+ self?.updateInfoPanelPosition()+ self?.syncCarouselFocusTargets()+ }+ } else {+ listView.collectionViewLayout.invalidateLayout()+ listView.reloadData()+ infoPanelView.isHidden = true+ applyShaderBackground(force: true)}}@@ -640,13 +703,22 @@ class GameListLandscapeView: BaseView {}}- //MARK: - 聚焦信息与背景联动+ //MARK: - Focused info and background++ private enum AppliedCarouselBackground: Equatable {+ case shader+ case gameImage(String)+ }func updateFocusedGameInfo() {+ guard isCarouselEnabled else {+ infoPanelView.isHidden = true+ applyShaderBackground()+ return+ }guard let game = focusedGame else {infoPanelView.isHidden = true- NotificationCenter.default.post(name: R.NotificationName.LandscapeBackgroundChange,- object: LandscapeBackgroundView.Background.shader(reload: false))+ applyShaderBackground()DispatchQueue.main.async { [weak self] inself?.syncCarouselFocusTargets()}@@ -662,55 +734,151 @@ class GameListLandscapeView: BaseView {subTitleLabel.title = R.string.localizable.readyGameInfoNeverPlayed()}- updateBackground(for: game)+ if shouldApplyBackgroundForCurrentPage {+ applyCarouselBackground(for: carouselLayout.currentPage)+ }DispatchQueue.main.async { [weak self] inself?.syncCarouselFocusTargets()}}- ///聚焦游戏有横幅背景图时展示静态图 否则回落到动态Shader背景- private func updateBackground(for game: Game) {+ /// Banner if the focused game has one; otherwise fall back to the live Shader.+ private func updateBackground(for game: Game, force: Bool = false) {+ let next: AppliedCarouselBackgroundlet background: LandscapeBackgroundView.Backgroundif let bannerImage = game.bannerImage {+ next = .gameImage(game.id)background = .image(bannerImage, effects: .default)} else {+ next = .shaderbackground = .shader(reload: false)}+ guard force || next != appliedCarouselBackground else { return }+ appliedCarouselBackground = nextNotificationCenter.default.post(name: R.NotificationName.LandscapeBackgroundChange,object: background)}+ private func applyCarouselBackground(for page: Int, force: Bool = false) {+ guard isCarouselEnabled, page >= 0, page < displayGames.count else {+ applyShaderBackground(force: force)+ return+ }+ updateBackground(for: displayGames[page], force: force)+ }++ private func applyShaderBackground(force: Bool = false) {+ guard force || appliedCarouselBackground != .shader else { return }+ appliedCarouselBackground = .shader+ NotificationCenter.default.post(name: R.NotificationName.LandscapeBackgroundChange,+ object: LandscapeBackgroundView.Background.shader(reload: false))+ }++ /// Keep the last committed background while cards fly past; apply as soon as the destination is known.+ private var shouldApplyBackgroundForCurrentPage: Bool {+ if let settlingBackgroundPage {+ return carouselLayout.currentPage == settlingBackgroundPage+ }+ return !carouselView.isDragging && !carouselView.isDecelerating+ }++ private func finishCarouselBackgroundSettling() {+ let page = settlingBackgroundPage ?? carouselLayout.currentPage+ settlingBackgroundPage = nil+ applyCarouselBackground(for: page)+ }++ private func focusCarouselPage(_ page: Int, animated: Bool) {+ settlingBackgroundPage = page+ applyCarouselBackground(for: page)+ carouselLayout.setCurrentPage(page, animated: animated)+ }++ private enum ThemeSheetRow {+ case dynamicBackground+ case enableCarousel+ case carouselStyle+ case backgroundMusic+ case soundEffects+ case more+ }++ private func themeSheetRows() -> [ThemeSheetRow] {+ var rows: [ThemeSheetRow] = [.dynamicBackground, .enableCarousel]+ if isCarouselEnabled {+ rows.append(.carouselStyle)+ }+ rows.append(contentsOf: [.backgroundMusic, .soundEffects, .more])+ return rows+ }++ private func themeSheetCells() -> [ASListPage.Cell] {+ themeSheetRows().map { row in+ switch row {+ case .dynamicBackground:+ return .iconTitleChevronCell(icon: .symbolImage(R.image.advance_shader_iconSymbols()),+ title: R.string.localizable.dynamicBackground(),+ chevronTitle: ShaderToy.getUsingShaderToy().title)+ case .enableCarousel:+ return .iconTitleDetailSwitchCell(icon: .symbol(.squareStack3dUpFill),+ title: R.string.localizable.enableCarouselStyle(),+ state: isCarouselEnabled ? .on : .off,+ enablePressEffect: false)+ case .carouselStyle:+ return .iconTitleChevronCell(icon: .symbol(.squareStack),+ title: R.string.localizable.carouselStyle())+ case .backgroundMusic:+ return .iconTitleChevronCell(icon: .symbol(.musicNote),+ title: R.string.localizable.backgroundMusic(),+ chevronTitle: BackgroundMusicKit.shared.displayName)+ case .soundEffects:+ return .iconTitleChevronCell(icon: .symbol(.speakerWave2),+ title: R.string.localizable.soundEffects(),+ chevronTitle: FocusSoundEffects.shared.displayName)+ case .more:+ return .iconTitleChevronCell(icon: .symbolImage(R.image.themeRegular_iconSymbols()),+ title: R.string.localizable.moreSettingTitle())+ }+ }+ }+private func showThemeSheet() {- ChevronSheetView.show(icon: .symbolImage(R.image.themeRegular_iconSymbols()),- title: R.string.localizable.themeSettingTitle(),- cellOptions: [- .iconTitleChevronCell(icon: .symbolImage(R.image.advance_shader_iconSymbols()),- title: R.string.localizable.dynamicBackground(),- chevronTitle: ShaderToy.getUsingShaderToy().title),- .iconTitleChevronCell(icon: .symbol(.squareStack),- title: R.string.localizable.carouselStyle()),- .iconTitleChevronCell(icon: .symbol(.musicNote),- title: R.string.localizable.backgroundMusic(),- chevronTitle: BackgroundMusicKit.shared.displayName),- .iconTitleChevronCell(icon: .symbol(.speakerWave2),- title: R.string.localizable.soundEffects(),- chevronTitle: FocusSoundEffects.shared.displayName),- .iconTitleChevronCell(icon: .symbolImage(R.image.themeRegular_iconSymbols()),- title: R.string.localizable.moreSettingTitle()),- ], completion: { [weak self] index in- guard let self, let index else { return }- if index == 0 {- self.showDynamicBackgroundSheet()- } else if index == 1 {- self.showCarouselStyleSheet()- } else if index == 2 {- self.showBackgroundMusicSheet()- } else if index == 3 {- self.showSoundEffectsSheet()- } else if index == 4 {- ThemeSettingView.show()- }- })+ ASSheetView.show(.init(style: .simpleList(icon: .symbolImage(R.image.themeRegular_iconSymbols()),+ title: R.string.localizable.themeSettingTitle(),+ options: themeSheetCells().map { [$0] })),+ action: { [weak self] action, updation in+ guard let self else { return .dismiss() }++ if action.isTapBackground || action.listPageValue?.navigationValue?.isTapClose == true {+ return .dismiss()+ }++ guard let normal = action.listPageValue?.normalItemValue else { return .none }+ let rows = self.themeSheetRows()+ let index = normal.indexPath.section+ guard rows.indices.contains(index) else { return .none }++ switch rows[index] {+ case .enableCarousel:+ guard let isOn = normal.subActions?.extraValue as? Bool else { return .none }+ LandscapeCarouselStyle.isCarouselEnabled = isOn+ self.reloadAll(keepFocus: true)+ updation?(.simpleList(icon: .symbolImage(R.image.themeRegular_iconSymbols()),+ title: R.string.localizable.themeSettingTitle(),+ options: self.themeSheetCells().map { [$0] }))+ return .none+ case .dynamicBackground:+ return .dismiss { self.showDynamicBackgroundSheet() }+ case .carouselStyle:+ return .dismiss { self.showCarouselStyleSheet() }+ case .backgroundMusic:+ return .dismiss { self.showBackgroundMusicSheet() }+ case .soundEffects:+ return .dismiss { self.showSoundEffectsSheet() }+ case .more:+ return .dismiss { ThemeSettingView.show() }+ }+ })}private func showDynamicBackgroundSheet() {@@ -1168,102 +1336,195 @@ class GameListLandscapeView: BaseView {}}+ //MARK: - List layout (carousel disabled)++ /// Match GameListView cover math; one horizontally scrolling row per platform.+ private func createListLayout() -> UICollectionViewLayout {+ UICollectionViewCompositionalLayout { [weak self] sectionIndex, env in+ guard let self, self.displaySections.indices.contains(sectionIndex) else { return nil }+ let gameType = self.displaySections[sectionIndex].gameType+ let itemSpacing = R.Size.ContentSpaceMedium - R.Size.GamesListSelectionEdge * 2+ let sectionInsetTop = R.Size.ContentSpaceTiny+ let sectionInsetBottom = R.Size.ContentSpaceMedium+ let hideTitle = R.Style.GamesHideTitle++ var column: CGFloat+ if UIDevice.isPad {+ column = UIDevice.isPadMini ? 5 : 6+ } else {+ column = UIDevice.isSmallScreenPhone ? 4 : 5+ }++ let totleSpacing = (R.Size.ContentSpaceMedium - R.Size.GamesListSelectionEdge) * 2 + itemSpacing * (column - 1)+ let itemEstimatedWidth = max((env.container.contentSize.width - totleSpacing) / column, 1)+ let coverWidth = max(itemEstimatedWidth - R.Size.GamesListSelectionEdge * 2, 1)+ let coverHeight = coverWidth / R.Size.GameCoverRatio(gameType: gameType)+ let titleHeight = hideTitle ? 0 : (R.Size.ContentSpaceSmall + R.Font.Footnote().lineHeight)+ let itemEstimatedHeight = R.Size.GamesListSelectionEdge + coverHeight + titleHeight + R.Size.GamesListSelectionEdge+ self.listCoverSizes[gameType] = CGSize(width: coverWidth, height: coverHeight)++ let item = NSCollectionLayoutItem(layoutSize: NSCollectionLayoutSize(widthDimension: .absolute(itemEstimatedWidth),+ heightDimension: .absolute(itemEstimatedHeight)))+ let group = NSCollectionLayoutGroup.horizontal(layoutSize: NSCollectionLayoutSize(widthDimension: .absolute(itemEstimatedWidth),+ heightDimension: .absolute(itemEstimatedHeight)),+ subitems: [item])+ let section = NSCollectionLayoutSection(group: group)+ section.orthogonalScrollingBehavior = .continuous+ section.interGroupSpacing = itemSpacing+ let groupHorizontalInset = R.Size.ContentSpaceMedium - R.Size.GamesListSelectionEdge+ section.contentInsets = NSDirectionalEdgeInsets(top: sectionInsetTop,+ leading: groupHorizontalInset,+ bottom: sectionInsetBottom,+ trailing: groupHorizontalInset)+ section.supplementariesFollowContentInsets = false++ let headerItem = NSCollectionLayoutBoundarySupplementaryItem(layoutSize: NSCollectionLayoutSize(widthDimension: .fractionalWidth(1),+ heightDimension: .estimated(R.Size.ItemHeightSmall)),+ elementKind: UICollectionView.elementKindSectionHeader,+ alignment: .top)+ section.boundarySupplementaryItems = [headerItem]+ return section+ }+ }++ /// Avoid `=== listView` / `=== carouselView` in data source — those lazy vars re-enter during init.+ private func isListCollectionView(_ collectionView: UICollectionView) -> Bool {+ collectionView.collectionViewLayout is UICollectionViewCompositionalLayout+ }++ private func isCarouselCollectionView(_ collectionView: UICollectionView) -> Bool {+ collectionView.collectionViewLayout is CollectionViewPagingLayout+ }++ private func applyContentMode() {+ let enabled = isCarouselEnabled+ carouselView.isHidden = !enabled+ carouselView.isUserInteractionEnabled = enabled+ listView.isHidden = enabled+ listView.isUserInteractionEnabled = !enabled+ if enabled {+ if carouselView.dataSource == nil {+ carouselView.dataSource = self+ carouselView.delegate = self+ }+ infoPanelView.isUserInteractionEnabled = true+ applyCarouselPagingMode()+ } else {+ // Paging layout observes bounds and async performBatchUpdates.+ // A hidden carousel with a live dataSource crashes when games are+ // inserted (8→9, 0 inserted) after returning from Import.+ carouselView.dataSource = nil+ carouselView.delegate = nil+ infoPanelView.isHidden = true+ infoPanelView.alpha = 1+ infoPanelView.isUserInteractionEnabled = false+ lastPanelAnchor = .zero+ }+ }++ private func listGame(at indexPath: IndexPath) -> Game? {+ guard displaySections.indices.contains(indexPath.section),+ displaySections[indexPath.section].games.indices.contains(indexPath.item) else {+ return nil+ }+ return displaySections[indexPath.section].games[indexPath.item]+ }++ private func listIndexPath(for gameId: String) -> IndexPath? {+ for (section, entry) in displaySections.enumerated() {+ if let row = entry.games.firstIndex(where: { $0.id == gameId }) {+ return IndexPath(item: row, section: section)+ }+ }+ return nil+ }++ private func showListGameEditSheet(game: Game) {+ GameOptionsView.show(scene: .common,+ games: [game],+ shouldHide: {+ $0 == .genHomeMenu || $0 == .delete+ })+ }+//MARK: - Carousel paging & info panel- /// Snapshot keeps system paging. Scale/Stack allow inertial flicks that snap onto a card.+ /// Between `.fast` (0.99) and `.normal` (0.998). Full-width cards need a short tail, not a long coast.+ private static let carouselDecelerationRate = UIScrollView.DecelerationRate(rawValue: 0.991)++ /// Continuous scroll with page-aligned landing: UIKit owns bounce/deceleration.private func applyCarouselPagingMode() {- let paging = usesSystemCarouselPaging- carouselView.isPagingEnabled = paging- isCarouselUserScrolling = false- isCarouselSnapping = false+ carouselView.isPagingEnabled = false+ carouselView.decelerationRate = Self.carouselDecelerationRate+ carouselView.alwaysBounceHorizontal = trueinfoPanelView.alpha = 1infoPanelView.isUserInteractionEnabled = true}- /// Maps pan velocity (pt/ms) to pages.- /// Light/normal → 1 page; a mid skip sits between that and a firm flick; hardest → first/last.+ /// Normalized flick speed in pt/ms. UIKit reports pt/s on most builds.private func carouselFlickSpeed(_ velocityX: CGFloat) -> CGFloat {var speed = abs(velocityX)- // Documented as pt/ms; if a build reports pt/s the values are hundreds+.if speed > 20 {speed /= 1000}return speed}+ /// Discrete flick bands: 1...5 pages, and only an all-out flick jumps to the end.+ /// Thresholds are shifted +2 bands from the previous curve (old 3-page force = new 1-page).private func carouselPagesForVelocity(_ velocityX: CGFloat, pageCount: Int) -> Int {let speed = carouselFlickSpeed(velocityX)- if speed < 0.50 {+ if speed < 0.25 {return 0}- if speed < 2.5 {+ if speed < 2.0 {return 1}- if speed < 3.0 {+ if speed < 2.8 {return 2}- if speed < 3.5 {- let t = (speed - 3.0) / 0.40- return min(1 + Int((2.0 * t).rounded()), pageCount)- }- if speed < 4.0 {- let t = (speed - 3.5) / 0.50- return min(2 + Int((4.0 * t).rounded()), pageCount)+ if speed < 3.2 {+ return 3}- if speed < 4.50 {- let t = (speed - 4.0) / 0.60- return min(4 + Int((8.0 * t).rounded()), pageCount)+ if speed < 3.4 {+ return 4}- if speed < 5.0 {- let t = (speed - 4.50) / 0.70- return min(8 + Int((20.0 * t).rounded()), pageCount)+ if speed < 3.5 {+ return 5}return pageCount}+ /// Page count comes from flick bands only. Proposed offset is used for direction, not distance.private func carouselTargetPage(offset: CGFloat,proposedOffset: CGFloat,velocityX: CGFloat,pageWidth: CGFloat,pageCount: Int) -> Int {guard pageCount > 0, pageWidth > 0 else { return 0 }- let fractional = offset / pageWidth- let pages = carouselPagesForVelocity(velocityX, pageCount: pageCount)+ let speed = carouselFlickSpeed(velocityX)++ guard speed >= 0.25 else {+ return min(max(Int((offset / pageWidth).rounded()), 0), pageCount - 1)+ }+let direction: Int- if pages == 0 {- direction = 0- } else if abs(proposedOffset - offset) > 0.5 {+ if abs(proposedOffset - offset) > 0.5 {direction = proposedOffset > offset ? 1 : -1} else {- // Full-width pages often project ~0; pan-right decreases contentOffset.direction = velocityX > 0 ? -1 : 1}- let raw: Int- if direction == 0 {- raw = Int(fractional.rounded())- } else if direction > 0 {- raw = Int(floor(fractional)) + pages- } else {- raw = Int(ceil(fractional)) - pages- }+ let pages = max(carouselPagesForVelocity(velocityX, pageCount: pageCount), 1)+ let raw = direction > 0+ ? Int(floor(offset / pageWidth)) + pages+ : Int(ceil(offset / pageWidth)) - pagesreturn min(max(raw, 0), pageCount - 1)}- private func settleCarouselAfterUserScroll() {- guard isCarouselUserScrolling || isCarouselSnapping else { return }- isCarouselUserScrolling = false- isCarouselSnapping = false- infoPanelView.alpha = 1- infoPanelView.isUserInteractionEnabled = true- updateFocusedGameInfo()- updateInfoPanelPosition()- syncCarouselFocusTargets()- transferCarouselCardFocusIfNeeded()- }-/// Info panel follows the focused cover's bottom edge and stays centered under it.private func updateInfoPanelPosition() {+ guard isCarouselEnabled else { return }let index = carouselLayout.currentPageguard index >= 0, index < displayGames.count,let cell = carouselView.cellForItem(at: IndexPath(item: index, section: 0)) as? GameLandscapeCarouselCell,@@ -1297,6 +1558,7 @@ class GameListLandscapeView: BaseView {/// Current cover is the only focusable target. Left/right change pages via the paging layout./// Do not put press/focus lift on `cardView` — the carousel layout owns that transform.private func syncCarouselFocusTargets() {+ guard isCarouselEnabled else { return }let current = carouselLayout.currentPagefor indexPath in carouselView.indexPathsForVisibleItems {guard let cell = carouselView.cellForItem(at: indexPath) as? GameLandscapeCarouselCell else { continue }@@ -1340,7 +1602,7 @@ class GameListLandscapeView: BaseView {let count = carouselView.numberOfItems(inSection: 0)let next = carouselLayout.currentPage + offsetguard count > 0, next >= 0, next < count else { return false }- carouselLayout.setCurrentPage(next, animated: true)+ focusCarouselPage(next, animated: true)return true}@@ -1391,11 +1653,41 @@ extension GameListLandscapeView: UICollectionViewDataSource {private var showsEmptyCard: Bool { displayGames.isEmpty }+ func numberOfSections(in collectionView: UICollectionView) -> Int {+ if isListCollectionView(collectionView) {+ return displaySections.count+ }+ return 1+ }+func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {+ if isListCollectionView(collectionView) {+ guard displaySections.indices.contains(section) else { return 0 }+ return displaySections[section].games.count+ }return showsEmptyCard ? 1 : displayGames.count}func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {+ if isListCollectionView(collectionView) {+ let cell = collectionView.dequeueReusableCell(withClass: GameCollectionViewCell.self, for: indexPath)+ if let game = listGame(at: indexPath) {+ let gameType = displaySections[indexPath.section].gameType+ cell.setData(game: game,+ isSelect: false,+ highlightString: nil,+ coverSize: listCoverSizes[gameType] ?? .zero,+ showTitle: !R.Style.GamesHideTitle,+ indexPath: indexPath)+ cell.isFocusable = true+ cell.onFocusConfirm = {+ game.handleTapAction()+ return true+ }+ }+ return cell+ }+let cell = collectionView.dequeueReusableCell(withClass: LandscapeCarouselStyle.current.cellClass, for: indexPath)if showsEmptyCard {cell.setEmptyPlaceholder(cardSize: sizedCard(ratio: 0.7))@@ -1404,11 +1696,43 @@ extension GameListLandscapeView: UICollectionViewDataSource {}return cell}++ func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {+ guard isListCollectionView(collectionView),+ kind == UICollectionView.elementKindSectionHeader,+ displaySections.indices.contains(indexPath.section) else {+ return UICollectionReusableView()+ }+ let header = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withClass: GamesCollectionReusableView.self, for: indexPath)+ let entry = displaySections[indexPath.section]+ header.setData(gameType: entry.gameType,+ gamesCount: entry.games.count,+ allowsFold: false)+ header.backgroundColor = .clear+ header.didTapGameCount = nil+ header.didTapPlatform = {+ if entry.gameType != .unknown {+ ASWebView.show(url: R.URLs.History(gameType: entry.gameType))+ }+ }+ return header+ }}//MARK: - UICollectionViewDelegateextension GameListLandscapeView: UICollectionViewDelegate {+ func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool {+ if isListCollectionView(collectionView) {+ if let game = listGame(at: indexPath) {+ game.handleTapAction()+ }+ return false+ }+ return true+ }+func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {+ guard isCarouselCollectionView(collectionView) else { return }if showsEmptyCard {UIDevice.generateHaptic()NotificationCenter.default.post(name: R.NotificationName.HomeSelectionChange, object: HomeTabBar.BarSelection.imports)@@ -1416,24 +1740,21 @@ extension GameListLandscapeView: UICollectionViewDelegate {}// Tap a side card to focus it; tap the focused card to start the game.if indexPath.row != carouselLayout.currentPage {- carouselLayout.setCurrentPage(indexPath.row)+ focusCarouselPage(indexPath.row, animated: true)} else if let game = focusedGame {UIDevice.generateHaptic()game.handleTapAction()}}- func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {- guard scrollView === carouselView, !usesSystemCarouselPaging else { return }- isCarouselUserScrolling = true- }-func scrollViewWillEndDragging(_ scrollView: UIScrollView,withVelocity velocity: CGPoint,targetContentOffset: UnsafeMutablePointer<CGPoint>) {- guard scrollView === carouselView, !usesSystemCarouselPaging, !showsEmptyCard else { return }+ guard let collectionView = scrollView as? UICollectionView,+ isCarouselCollectionView(collectionView),+ !showsEmptyCard else { return }let pageWidth = scrollView.bounds.width- let pageCount = carouselView.numberOfItems(inSection: 0)+ let pageCount = collectionView.numberOfItems(inSection: 0)guard pageWidth > 0, pageCount > 0 else { return }let targetPage = carouselTargetPage(offset: scrollView.contentOffset.x,@@ -1441,45 +1762,46 @@ extension GameListLandscapeView: UICollectionViewDelegate {velocityX: velocity.x,pageWidth: pageWidth,pageCount: pageCount)- let targetX = CGFloat(targetPage) * pageWidth- let distancePages = abs(scrollView.contentOffset.x - targetX) / pageWidth-- // Same settle path as tapping a card: system setContentOffset animation.- targetContentOffset.pointee = scrollView.contentOffset-- if distancePages < 0.002 {- carouselLayout.setCurrentPage(targetPage, animated: false)- settleCarouselAfterUserScroll()- return- }-- isCarouselSnapping = true- carouselLayout.setCurrentPage(targetPage, animated: true) { [weak self] in- self?.settleCarouselAfterUserScroll()- }+ // Keep system deceleration; only pin the destination to a card.+ targetContentOffset.pointee = CGPoint(x: CGFloat(targetPage) * pageWidth, y: 0)+ // Apply the landing card's background now so cards flying past do not flash theirs.+ settlingBackgroundPage = targetPage+ applyCarouselBackground(for: targetPage)+ }++ func scrollViewWillBeginDragging(_ scrollView: UIScrollView) {+ guard let collectionView = scrollView as? UICollectionView,+ isCarouselCollectionView(collectionView) else { return }+ settlingBackgroundPage = nil}func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) {- guard scrollView === carouselView, !usesSystemCarouselPaging else { return }- if !decelerate && !isCarouselSnapping {- settleCarouselAfterUserScroll()+ guard let collectionView = scrollView as? UICollectionView,+ isCarouselCollectionView(collectionView) else { return }+ if !decelerate {+ finishCarouselBackgroundSettling()}}func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {- guard scrollView === carouselView, !usesSystemCarouselPaging else { return }- if !isCarouselSnapping {- settleCarouselAfterUserScroll()- }+ guard let collectionView = scrollView as? UICollectionView,+ isCarouselCollectionView(collectionView) else { return }+ finishCarouselBackgroundSettling()+ syncCarouselFocusTargets()+ transferCarouselCardFocusIfNeeded()}func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) {- guard scrollView === carouselView, !usesSystemCarouselPaging else { return }- settleCarouselAfterUserScroll()+ guard let collectionView = scrollView as? UICollectionView,+ isCarouselCollectionView(collectionView) else { return }+ finishCarouselBackgroundSettling()+ syncCarouselFocusTargets()+ transferCarouselCardFocusIfNeeded()}func scrollViewDidScroll(_ scrollView: UIScrollView) {- guard scrollView === carouselView else { return }+ guard let collectionView = scrollView as? UICollectionView,+ isCarouselCollectionView(collectionView) else { return }updateInfoPanelPosition()}}@@ -1487,12 +1809,18 @@ extension GameListLandscapeView: UICollectionViewDelegate {//MARK: - CollectionViewPagingLayoutDelegateextension GameListLandscapeView: CollectionViewPagingLayoutDelegate {func onCurrentPageChanged(layout: CollectionViewPagingLayout, currentPage: Int) {- if isCarouselUserScrolling || isCarouselSnapping {- return- }+ guard isCarouselEnabled else { return }updateFocusedGameInfo()updateInfoPanelPosition()syncCarouselFocusTargets()transferCarouselCardFocusIfNeeded()}}++// MARK: - UIGestureRecognizerDelegate+extension GameListLandscapeView: UIGestureRecognizerDelegate {+ func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {+ // Long-press should win over the cell tap.+ return false+ }+}diff --git a/ManicEmu/ManicEmu/Sources/Business/Games/Views/GamesCollectionReusableView.swift b/ManicEmu/ManicEmu/Sources/Business/Games/Views/GamesCollectionReusableView.swiftindex 85efd733..08e2b747 100644--- a/ManicEmu/ManicEmu/Sources/Business/Games/Views/GamesCollectionReusableView.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Games/Views/GamesCollectionReusableView.swift@@ -102,7 +102,7 @@ class GamesCollectionReusableView: UICollectionReusableView {}}- func setData(gameType: GameType, highlightString: String? = nil, gamesCount: Int = 0, isFolded: Bool = false) {+ func setData(gameType: GameType, highlightString: String? = nil, gamesCount: Int = 0, isFolded: Bool = false, allowsFold: Bool = true) {if R.Style.GamesGroupTitleStyle == .brand && gameType != .unknown {titleContainer.isHidden = truebrandImageContainer.isHidden = false@@ -122,7 +122,8 @@ class GamesCollectionReusableView: UICollectionReusableView {}gamesCountButton.setTitleString("\(gamesCount) \(R.string.localizable.tabbarTitleGames())")- if UIDevice.isPhone, UIDevice.isLandscape {+ gamesCountButton.isUserInteractionEnabled = allowsFold+ if !allowsFold || (UIDevice.isPhone && UIDevice.isLandscape) {gamesCountButton.setIcon(nil)} else {gamesCountButton.setIcon(.symbol(isFolded ? .chevronDown : .chevronUp, colors: [R.Color.LabelSecondary]))diff --git a/ManicEmu/ManicEmu/Sources/Tools/Others/OnlineCoverManager.swift b/ManicEmu/ManicEmu/Sources/Tools/Others/OnlineCoverManager.swiftindex 21522a3d..e09098d8 100644--- a/ManicEmu/ManicEmu/Sources/Tools/Others/OnlineCoverManager.swift+++ b/ManicEmu/ManicEmu/Sources/Tools/Others/OnlineCoverManager.swift@@ -371,7 +371,16 @@ class OnlineCoverManager {request.addValue("Bearer \(R.Cipher.DeepSeek)", forHTTPHeaderField: "Authorization")request.addValue("application/json", forHTTPHeaderField: "Content-Type")request.addValue("application/json", forHTTPHeaderField: "Accept")- request.httpBody = ["frequency_penalty": 0.7, "max_tokens": 2048, "model": "deepseek-v4-flash", "presence_penalty": 0.7, "stream" : false, "temperature" : 1.3, "top_p" : 0.9, "response_format" : ["type": "json_object"], "messages": [["content": "\(content)", "role":"user"]]].jsonData()+ // Flash thinks by default; disable it so a short JSON title does not burn reasoning tokens.+ request.httpBody = [+ "model": "deepseek-flash",+ "max_tokens": 128,+ "stream": false,+ "temperature": 1.3,+ "thinking": ["type": "disabled"],+ "response_format": ["type": "json_object"],+ "messages": [["content": content, "role": "user"]]+ ].jsonData()let task = URLSession.shared.dataTask(with: request) { data, response, error inif let _ = error {completion?(name)