diff --git a/Cores/DeltaCore b/Cores/DeltaCore index 62e30af..81362dd 160000 --- a/Cores/DeltaCore +++ b/Cores/DeltaCore @@ -1 +1 @@ -Subproject commit 62e30af00e4e67ad1d5f786c21beba749c50aa61 +Subproject commit 81362dd5def310f4dd908513574c7e2fd10c7d75 diff --git a/Delta/Base.lproj/Settings.storyboard b/Delta/Base.lproj/Settings.storyboard index 77eb2ba..5eb7b07 100644 --- a/Delta/Base.lproj/Settings.storyboard +++ b/Delta/Base.lproj/Settings.storyboard @@ -1,9 +1,9 @@ - + - + @@ -279,26 +279,26 @@ - + - + - @@ -311,33 +311,67 @@ - - + + + + + + - + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -621,12 +655,13 @@ - + + - + diff --git a/Delta/Emulation/GameViewController.swift b/Delta/Emulation/GameViewController.swift index 41d165c..83a3147 100644 --- a/Delta/Emulation/GameViewController.swift +++ b/Delta/Emulation/GameViewController.swift @@ -112,6 +112,7 @@ class GameViewController: DeltaCore.GameViewController } self.updateControllers() + self.updateAudio() self.presentedGyroAlert = false } @@ -935,6 +936,16 @@ extension GameViewController: CheatsViewControllerDelegate } } +//MARK: - Audio - +/// Audio +private extension GameViewController +{ + func updateAudio() + { + self.emulatorCore?.audioManager.respectsSilentMode = Settings.respectSilentMode + } +} + //MARK: - Sustain Buttons - private extension GameViewController { @@ -1194,8 +1205,12 @@ private extension GameViewController self.updateControllerSkin() } - case .translucentControllerSkinOpacity: self.controllerView.translucentControllerSkinOpacity = Settings.translucentControllerSkinOpacity + case .translucentControllerSkinOpacity: + self.controllerView.translucentControllerSkinOpacity = Settings.translucentControllerSkinOpacity + case .respectSilentMode: + self.updateAudio() + case .syncingService, .isAltJITEnabled: break } } diff --git a/Delta/Settings/Settings.swift b/Delta/Settings/Settings.swift index a6c90c0..0d06860 100644 --- a/Delta/Settings/Settings.swift +++ b/Delta/Settings/Settings.swift @@ -39,6 +39,7 @@ extension Settings case isButtonHapticFeedbackEnabled case isThumbstickHapticFeedbackEnabled case isAltJITEnabled + case respectSilentMode } } @@ -62,6 +63,7 @@ struct Settings #keyPath(UserDefaults.sortSaveStatesByOldestFirst): true, #keyPath(UserDefaults.isPreviewsEnabled): true, #keyPath(UserDefaults.isAltJITEnabled): false, + #keyPath(UserDefaults.respectSilentMode): true, Settings.preferredCoreSettingsKey(for: .ds): MelonDS.core.identifier] as [String : Any] UserDefaults.standard.register(defaults: defaults) @@ -208,6 +210,17 @@ extension Settings } } + static var respectSilentMode: Bool { + get { + let respectSilentMode = UserDefaults.standard.respectSilentMode + return respectSilentMode + } + set { + UserDefaults.standard.respectSilentMode = newValue + NotificationCenter.default.post(name: .settingsDidChange, object: nil, userInfo: [NotificationUserInfoKey.name: Name.respectSilentMode]) + } + } + static func preferredCore(for gameType: GameType) -> DeltaCoreProtocol? { let key = self.preferredCoreSettingsKey(for: gameType) @@ -405,4 +418,6 @@ private extension UserDefaults @NSManaged var isPreviewsEnabled: Bool @NSManaged var isAltJITEnabled: Bool + + @NSManaged var respectSilentMode: Bool } diff --git a/Delta/Settings/SettingsViewController.swift b/Delta/Settings/SettingsViewController.swift index 282a0ee..f619548 100644 --- a/Delta/Settings/SettingsViewController.swift +++ b/Delta/Settings/SettingsViewController.swift @@ -20,6 +20,7 @@ private extension SettingsViewController case controllers case controllerSkins case controllerOpacity + case gameAudio case hapticFeedback case syncing case hapticTouch @@ -56,6 +57,7 @@ class SettingsViewController: UITableViewController @IBOutlet private var controllerOpacityLabel: UILabel! @IBOutlet private var controllerOpacitySlider: UISlider! + @IBOutlet private var respectSilentModeSwitch: UISwitch! @IBOutlet private var buttonHapticFeedbackEnabledSwitch: UISwitch! @IBOutlet private var thumbstickHapticFeedbackEnabledSwitch: UISwitch! @IBOutlet private var previewsEnabledSwitch: UISwitch! @@ -160,6 +162,8 @@ private extension SettingsViewController self.controllerOpacitySlider.value = Float(Settings.translucentControllerSkinOpacity) self.updateControllerOpacityLabel() + self.respectSilentModeSwitch.isOn = Settings.respectSilentMode + self.syncingServiceLabel.text = Settings.syncingService?.localizedName do @@ -248,6 +252,11 @@ private extension SettingsViewController Settings.isPreviewsEnabled = sender.isOn } + @IBAction func toggleRespectSilentMode(_ sender: UISwitch) + { + Settings.respectSilentMode = sender.isOn + } + func openTwitter(username: String) { let twitterAppURL = URL(string: "twitter://user?screen_name=" + username)! @@ -290,7 +299,7 @@ private extension SettingsViewController self.tableView.selectRow(at: selectedIndexPath, animated: true, scrollPosition: .none) } - case .localControllerPlayerIndex, .preferredControllerSkin, .translucentControllerSkinOpacity, .isButtonHapticFeedbackEnabled, .isThumbstickHapticFeedbackEnabled, .isAltJITEnabled: break + case .localControllerPlayerIndex, .preferredControllerSkin, .translucentControllerSkinOpacity, .respectSilentMode, .isButtonHapticFeedbackEnabled, .isThumbstickHapticFeedbackEnabled, .isAltJITEnabled: break } } @@ -367,7 +376,7 @@ extension SettingsViewController let preferredCore = Settings.preferredCore(for: .ds) cell.detailTextLabel?.text = preferredCore?.metadata?.name.value ?? preferredCore?.name ?? NSLocalizedString("Unknown", comment: "") - case .controllerOpacity, .hapticFeedback, .hapticTouch, .patreon, .credits: break + case .controllerOpacity, .gameAudio, .hapticFeedback, .hapticTouch, .patreon, .credits: break } return cell @@ -383,7 +392,7 @@ extension SettingsViewController case .controllers: self.performSegue(withIdentifier: Segue.controllers.rawValue, sender: cell) case .controllerSkins: self.performSegue(withIdentifier: Segue.controllerSkins.rawValue, sender: cell) case .cores: self.performSegue(withIdentifier: Segue.dsSettings.rawValue, sender: cell) - case .controllerOpacity, .hapticFeedback, .hapticTouch, .syncing: break + case .controllerOpacity, .gameAudio, .hapticFeedback, .hapticTouch, .syncing: break case .patreon: let patreonURL = URL(string: "altstore://patreon")!