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 Slow Motion feature.
Daiuno866ddc80b0cc
diff --git a/.gitignore b/.gitignoreindex fcf80a64..cb07089e 100644--- a/.gitignore+++ b/.gitignore@@ -102,7 +102,6 @@ AppStoreConnect.claudeCLAUDE.mdSKILL.md-.xcodebuildmcp#cursor.cursordiff --git a/Dependencies/Libretro b/Dependencies/Libretroindex 6e01279f..837894b5 160000--- a/Dependencies/Libretro+++ b/Dependencies/Libretro@@ -1 +1 @@-Subproject commit 6e01279fa2c3b5d4bc6611abc815ca39210db177+Subproject commit 837894b594ad7dcce4bf2db7b9675ec6241a0a1cdiff --git a/ManicEmu/ManicEmu/Resources/en.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/en.lproj/Localizable.stringsindex 47bffef0..a6d65fbc 100644--- a/ManicEmu/ManicEmu/Resources/en.lproj/Localizable.strings+++ b/ManicEmu/ManicEmu/Resources/en.lproj/Localizable.strings@@ -1124,3 +1124,8 @@ Press the controller button to complete mapping...";"JitAutoEnableOnLaunch" = "Enable JIT on Launch";"JitAutoEnableOnLaunchDesc" = "Make sure the debug environment is ready before launching the app.";"JitSupportedDesc" = "Cores that support JIT: %@";++"SlowMotion" = "Slow Motion";+"SlowMotionRatio" = "Slow Motion %@";+"SlowMotionSpeedLimit" = "Maximum speed limited to 2x! Upgrade to Premium for 5x slow motion";+"SlowMotionDesc" = "Slow motion has lower priority than fast forward. If fast forward is enabled, slow motion turns off automatically.";diff --git a/ManicEmu/ManicEmu/Resources/zh-Hans.lproj/Localizable.strings b/ManicEmu/ManicEmu/Resources/zh-Hans.lproj/Localizable.stringsindex f721c1fc..c5e53200 100644--- a/ManicEmu/ManicEmu/Resources/zh-Hans.lproj/Localizable.strings+++ b/ManicEmu/ManicEmu/Resources/zh-Hans.lproj/Localizable.strings@@ -1119,3 +1119,8 @@"JitAutoEnableOnLaunch" = "启动时开启 JIT";"JitAutoEnableOnLaunchDesc" = "请确保启动应用前调试环境已就绪。";"JitSupportedDesc" = "支持 JIT 的核心:%@";++"SlowMotion" = "慢放";+"SlowMotionRatio" = "慢放%@";+"SlowMotionSpeedLimit" = "你的最高慢放是x2!请升级成为会员解锁最高x5倍慢放";+"SlowMotionDesc" = "慢放的优先级低于加速。如果开启了加速,慢放会自动关闭。";diff --git a/ManicEmu/ManicEmu/Sources/Business/Common/Models/ExtraKey.swift b/ManicEmu/ManicEmu/Sources/Business/Common/Models/ExtraKey.swiftindex 47b62a9a..e3447820 100644--- a/ManicEmu/ManicEmu/Sources/Business/Common/Models/ExtraKey.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Common/Models/ExtraKey.swift@@ -87,4 +87,5 @@ enum ExtraKey: String {case wiiControllercase dolphinManicInterpretercase autoEnableJITOnLaunch+ case slowMotionSpeed}diff --git a/ManicEmu/ManicEmu/Sources/Business/Games/Models/GameOption.swift b/ManicEmu/ManicEmu/Sources/Business/Games/Models/GameOption.swiftindex b1b404b9..b55a5fb0 100644--- a/ManicEmu/ManicEmu/Sources/Business/Games/Models/GameOption.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Games/Models/GameOption.swift@@ -80,7 +80,8 @@ enum GameOption: Int, CaseIterable {symbianDevice,wiiControllerMode,coverScraping,- dolphinCpuCore+ dolphinCpuCore,+ slowMotion//When adding a new option, make sure to add it at the end; otherwise, it might affect the existing Prefference configurations@@ -224,6 +225,8 @@ enum GameOption: Int, CaseIterable {.symbolImage(R.image.online_iconSymbols())case .symbianDevice:.symbol(.candybarphone)+ case .slowMotion:+ .symbol(.tortoise)}}@@ -371,6 +374,8 @@ enum GameOption: Int, CaseIterable {R.string.localizable.coverScraping()case .dolphinCpuCore:R.string.localizable.cpuEmulationMethod()+ case .slowMotion:+ R.string.localizable.slowMotion()}}@@ -503,6 +508,7 @@ enum GameOption: Int, CaseIterable {.quickLoadState,.volume,.fastForward,+ .slowMotion,.shaders,.screenShot,.haptic,@@ -937,6 +943,19 @@ enum GameOption: Int, CaseIterable {return .chevron(R.Strings.DolphinCPUs[firstGameValue ? 0 : 1])}+ case .slowMotion:+ let extraKey = ExtraKey.slowMotionSpeed.rawValue+ let firstGameValue = firstGame.getExtraInt(key: extraKey) ?? 0+ if games.allSatisfy({+ ($0.getExtraInt(key: extraKey) ?? 0) == firstGameValue+ }) {+ if firstGameValue == 0 {+ return .chevron(R.string.localizable.gameSettingFastForwardResume())+ } else if let speed = SlowMotionSpeed(rawValue: firstGameValue) {+ return .chevron(speed.title)+ }+ }+case .rename,.cover,.skins,@@ -1223,11 +1242,11 @@ enum GameOption: Int, CaseIterable {}if PlayViewController.isWFCConnect {- allOptions.subtract([.saveState, .quickLoadState, .fastForward, .stateList, .cheatCode, .rewind])+ allOptions.subtract([.saveState, .quickLoadState, .fastForward, .stateList, .cheatCode, .rewind, .slowMotion])}if PlayViewController.isHardcoreMode {- allOptions.subtract([.quickLoadState, .cheatCode, .triggerPro, .rewind])+ allOptions.subtract([.quickLoadState, .cheatCode, .triggerPro, .rewind, .slowMotion])}if !game.supportRewind {@@ -1258,6 +1277,10 @@ enum GameOption: Int, CaseIterable {allOptions.remove(.dolphinCpuCore)}+ if !game.supportSlowMotion {+ allOptions.remove(.slowMotion)+ }+allOptions.subtract(disableOptionsForScene(scene))return Array(allOptions)diff --git a/ManicEmu/ManicEmu/Sources/Business/Games/Models/GameOptionPerform.swift b/ManicEmu/ManicEmu/Sources/Business/Games/Models/GameOptionPerform.swiftindex bd538553..590cf02d 100644--- a/ManicEmu/ManicEmu/Sources/Business/Games/Models/GameOptionPerform.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Games/Models/GameOptionPerform.swift@@ -1079,6 +1079,13 @@ extension GameOption {case .dolphinCpuCore:performStringAction(with: games, accessoryChange: accessoryChange)+ case .slowMotion:+ if performImmediately,+ let speed = GameOption.SlowMotionSpeed(rawValue: firstGame.getExtraInt(key: ExtraKey.slowMotionSpeed.rawValue) ?? 0) {+ performSlowMotion(games: games, speed: speed.next)+ } else {+ performStringAction(with: games, accessoryChange: accessoryChange)+ }}}@@ -1329,6 +1336,9 @@ extension GameOption {} else if self == .dolphinCpuCore {options = R.Strings.DolphinCPUsdetail = R.string.localizable.dolphinCPUDesc()+ } else if self == .slowMotion {+ options = GameOption.SlowMotionSpeed.allCases.map({ $0.title })+ detail = R.string.localizable.slowMotionDesc()}guard options.count > 0 else { return }@@ -1546,6 +1556,10 @@ extension GameOption {games.forEach({$0.updateExtra(key: ExtraKey.dolphinManicInterpreter.rawValue, value: index == 0)})+ } else if self == .slowMotion {+ if let speed = GameOption.SlowMotionSpeed(rawValue: index) {+ performSlowMotion(games: games, speed: speed)+ }}accessoryChange?()} else {@@ -1734,4 +1748,41 @@ extension GameOption {continued?()}}++ private func performSlowMotion(games: [Game],+ speed: GameOption.SlowMotionSpeed) {+ guard games.count > 0 else { return }+ if !PurchaseManager.isMember && speed.rawValue > GameOption.SlowMotionSpeed.two.rawValue {+ pauseEmulationIfNeed()++ UIView.makeAlert(identifier: R.Strings.PlayPurchaseAlertIdentifier,+ detail: R.string.localizable.slowMotionSpeedLimit(),+ cancelTitle: R.string.localizable.resetSpeed(),+ confirmTitle: R.string.localizable.goToUpgrade(),+ confirmAutoHide: false, cancelAction: {+ PlayViewController.updateSlowMotion(speed: .off)+ games.forEach({+ $0.updateExtra(key: ExtraKey.slowMotionSpeed.rawValue,+ value: GameOption.SlowMotionSpeed.off.rawValue)+ })+ resumeEmulationIfNeed()+ UIView.makeToast(message: R.string.localizable.gameSettingFastForwardResume())+ }, confirmAction: {+ topViewController()?.present(PurchaseViewController(), animated: true)+ }, hideAction: { type in+ if type == .other {+ resumeEmulationIfNeed()+ }+ })+ } else {+ games.forEach({+ $0.updateExtra(key: ExtraKey.slowMotionSpeed.rawValue,+ value: speed.rawValue)+ })+ if PlayViewController.isGaming {+ PlayViewController.updateSlowMotion(speed: speed)+ UIView.makeToast(message: speed == .off ? R.string.localizable.gameSettingFastForwardResume() : speed.title, identifier: "gameSpeed")+ }+ }+ }}diff --git a/ManicEmu/ManicEmu/Sources/Business/Games/Models/GameOptionTypes.swift b/ManicEmu/ManicEmu/Sources/Business/Games/Models/GameOptionTypes.swiftindex 20269e87..db3c7d60 100644--- a/ManicEmu/ManicEmu/Sources/Business/Games/Models/GameOptionTypes.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Games/Models/GameOptionTypes.swift@@ -482,4 +482,41 @@ extension GameOption {}}}++ enum SlowMotionSpeed: Int, CaseIterable {+ case off, one, two, three, four, five++ var title: String {+ if self == .off {+ return R.string.localizable.gameSettingFastForwardResume()+ } else {+ return R.string.localizable.slowMotionRatio(" x\(self.rawValue)")+ }+ }++ var next: SlowMotionSpeed {+ if let speed = SlowMotionSpeed(rawValue: self.rawValue + 1) {+ return speed+ } else {+ return .off+ }+ }++ var ratio: Float {+ switch self {+ case .off:+ return 1.0+ case .one:+ return 1.2+ case .two:+ return 1.5+ case .three:+ return 3+ case .four:+ return 5.0+ case .five:+ return 10.0+ }+ }+ }}diff --git a/ManicEmu/ManicEmu/Sources/Business/Games/Models/MappingOption.swift b/ManicEmu/ManicEmu/Sources/Business/Games/Models/MappingOption.swiftindex e095d2d3..4bfe38cc 100644--- a/ManicEmu/ManicEmu/Sources/Business/Games/Models/MappingOption.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Games/Models/MappingOption.swift@@ -53,6 +53,8 @@ enum MappingOption: String, CaseIterable {//v2.0.0 j2meSettings/dosSettings has been replaced with coreSettingscase coreSettingscase rewind+ //v2.0.1+ case slowMotion//Both the key and the value need to be uniquestatic let GameOptionMappings: BiMap<MappingOption, GameOption> = [@@ -121,6 +123,10 @@ enum MappingOption: String, CaseIterable {availableMappingOptions.append(.useKeyboardSkin)}+ if games.allSatisfy({ $0.supportSlowMotion }) {+ availableMappingOptions.append(.slowMotion)+ }+return availableMappingOptions}diff --git a/ManicEmu/ManicEmu/Sources/Business/Play/Models/Game.swift b/ManicEmu/ManicEmu/Sources/Business/Play/Models/Game.swiftindex 2710d1c2..fd904a34 100644--- a/ManicEmu/ManicEmu/Sources/Business/Play/Models/Game.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Play/Models/Game.swift@@ -1609,6 +1609,13 @@ class Game: Object, ObjectUpdatable {var isDolphinCore: Bool {gameType == .ngc || gameType == .wii}++ var supportSlowMotion: Bool {+ if isLibretroType && gameType != .symbian {+ return true+ }+ return false+ }}diff --git a/ManicEmu/ManicEmu/Sources/Business/Play/VIewControllers/PlayViewController.swift b/ManicEmu/ManicEmu/Sources/Business/Play/VIewControllers/PlayViewController.swiftindex 80402330..ff6c2787 100644--- a/ManicEmu/ManicEmu/Sources/Business/Play/VIewControllers/PlayViewController.swift+++ b/ManicEmu/ManicEmu/Sources/Business/Play/VIewControllers/PlayViewController.swift@@ -987,6 +987,8 @@ class PlayViewController: GameViewController {Log.debug("长按结束,恢复原速度")} else if mappingKey == .rewind {LibretroCore.sharedInstance().setRewind(false)+ } else if mappingKey == .slowMotion {+ updateSlowMotion(speed: .off)}}}@@ -1320,6 +1322,14 @@ extension PlayViewController {return}LibretroCore.sharedInstance().setRewind(true)+ } else if mappingKey == .slowMotion {+ let speed: GameOption.SlowMotionSpeed+ if PurchaseManager.isMember {+ speed = .three+ } else {+ speed = .two+ }+ updateSlowMotion(speed: speed)}}}@@ -2938,6 +2948,7 @@ extension PlayViewController {DispatchQueue.main.asyncAfter(delay: 2.5) {self.updateFastforward(speed: self.manicGame.speed)self.updateRewind()+ self.trySlowMotionIfNeed()}}}@@ -3965,6 +3976,8 @@ extension PlayViewController {case .five:LibretroCore.sharedInstance().fastForward(7)}+ trySlowMotionIfNeed()+} else if manicGame.isJGenesisCore {switch speed {case .one:@@ -4172,6 +4185,28 @@ extension PlayViewController {bufferSizeStepMB: 10,mute: false)}++ private func updateSlowMotion(speed: GameOption.SlowMotionSpeed) {+ guard !manicGame.safeMode, manicGame.supportSlowMotion, !isHardcoreMode, !isWFCConnect else { return }+ LibretroCore.sharedInstance().setSlowmotionEnable(speed != .off, ratio: speed.ratio)+ }++ private func trySlowMotionIfNeed() {+ if isHardcoreMode || isWFCConnect {+ self.updateSlowMotion(speed: GameOption.SlowMotionSpeed.off)+ return+ }++ //If no fastforward, try using slow motion.+ if self.manicGame.speed == .one,+ let slowMotionSpeedRawValue = self.manicGame.getExtraInt(key: ExtraKey.slowMotionSpeed.rawValue),+ let slowMotionSpeed = GameOption.SlowMotionSpeed(rawValue: slowMotionSpeedRawValue),+ slowMotionSpeed != .off {+ self.updateSlowMotion(speed: slowMotionSpeed)+ } else {+ self.updateSlowMotion(speed: GameOption.SlowMotionSpeed.off)+ }+ }}//MARK: GameViewControllerDelegate代理@@ -4445,4 +4480,10 @@ extension PlayViewController {}return nil}++ static func updateSlowMotion(speed: GameOption.SlowMotionSpeed) {+ if let currentPlayViewController {+ currentPlayViewController.updateSlowMotion(speed: speed)+ }+ }}