diff --git a/Common/Collection View/GridCollectionViewCell.swift b/Common/Collection View/GridCollectionViewCell.swift index b5d5684..3261974 100644 --- a/Common/Collection View/GridCollectionViewCell.swift +++ b/Common/Collection View/GridCollectionViewCell.swift @@ -110,7 +110,7 @@ class GridCollectionViewCell: UICollectionViewCell self.textLabelFocusedVerticalSpacingConstraint?.isActive = true - self.textLabel.textColor = UIColor.white() + self.textLabel.textColor = UIColor.white } else @@ -120,7 +120,7 @@ class GridCollectionViewCell: UICollectionViewCell self.textLabelBottomAnchorConstraint?.isActive = true self.textLabelVerticalSpacingConstraint.isActive = true - self.textLabel.textColor = UIColor.black() + self.textLabel.textColor = UIColor.black } self.layoutIfNeeded() diff --git a/Common/Database/DatabaseManager.swift b/Common/Database/DatabaseManager.swift index 7da94c6..96a027f 100644 --- a/Common/Database/DatabaseManager.swift +++ b/Common/Database/DatabaseManager.swift @@ -192,7 +192,7 @@ extension DatabaseManager { let documentsDirectoryURL: URL - if UIDevice.current().userInterfaceIdiom == .tv + if UIDevice.current.userInterfaceIdiom == .tv { documentsDirectoryURL = FileManager.default.urlsForDirectory(FileManager.SearchPathDirectory.cachesDirectory, inDomains: FileManager.SearchPathDomainMask.userDomainMask).first! } diff --git a/Delta/Emulation/GameViewController.swift b/Delta/Emulation/GameViewController.swift index 8647d44..d0160b5 100644 --- a/Delta/Emulation/GameViewController.swift +++ b/Delta/Emulation/GameViewController.swift @@ -88,7 +88,7 @@ class GameViewController: DeltaCore.GameViewController if gameController is ControllerView && UIDevice.current().isVibrationSupported { - UIDevice.current().vibrate() + UIDevice.current.vibrate() } guard (input as? ControllerInput) != .menu else { return } @@ -190,7 +190,7 @@ extension GameViewController self.pausingGameController = gameController - let pauseViewController = segue.destinationViewController as! PauseViewController + let pauseViewController = segue.destination as! PauseViewController pauseViewController.pauseText = (self.game as? Game)?.name ?? NSLocalizedString("Delta", comment: "") pauseViewController.emulatorCore = self.emulatorCore pauseViewController.saveStatesViewControllerDelegate = self @@ -560,7 +560,7 @@ private extension GameViewController /// GameViewControllerDelegate extension GameViewController: GameViewControllerDelegate { - func gameViewController(gameViewController: DeltaCore.GameViewController, handleMenuInputFrom gameController: GameController) + func gameViewController(_ gameViewController: DeltaCore.GameViewController, handleMenuInputFrom gameController: GameController) { if self.selectingSustainedButtons { @@ -571,12 +571,12 @@ extension GameViewController: GameViewControllerDelegate self.performSegue(withIdentifier: "pause", sender: gameController) } - func gameViewControllerShouldResumeEmulation(gameViewController: DeltaCore.GameViewController) -> Bool + func gameViewControllerShouldResumeEmulation(_ gameViewController: DeltaCore.GameViewController) -> Bool { return self.pauseViewController == nil && !self.selectingSustainedButtons } - func gameViewControllerDidUpdate(gameViewController: DeltaCore.GameViewController) + func gameViewControllerDidUpdate(_ gameViewController: DeltaCore.GameViewController) { for semaphore in self.updateSemaphores { diff --git a/Delta/Game Selection/GamesViewController.swift b/Delta/Game Selection/GamesViewController.swift index 5682fe9..a600ca3 100644 --- a/Delta/Game Selection/GamesViewController.swift +++ b/Delta/Game Selection/GamesViewController.swift @@ -58,8 +58,8 @@ class GamesViewController: UIViewController self.pageControl.translatesAutoresizingMaskIntoConstraints = false self.pageControl.hidesForSinglePage = false self.pageControl.numberOfPages = 3 - self.pageControl.currentPageIndicatorTintColor = UIColor.purple() - self.pageControl.pageIndicatorTintColor = UIColor.lightGray() + self.pageControl.currentPageIndicatorTintColor = UIColor.purple + self.pageControl.pageIndicatorTintColor = UIColor.lightGray self.navigationController?.toolbar.addSubview(self.pageControl) self.pageControl.centerXAnchor.constraint(equalTo: (self.navigationController?.toolbar.centerXAnchor)!, constant: 0).isActive = true @@ -117,8 +117,8 @@ class GamesViewController: UIViewController // In a storyboard-based application, you will often want to do a little preparation before navigation override func prepare(for segue: UIStoryboardSegue, sender: AnyObject?) { - guard let sourceViewController = segue.sourceViewController as? GamesCollectionViewController else { return } - guard let destinationViewController = segue.destinationViewController as? GameViewController else { return } + guard let sourceViewController = segue.source as? GamesCollectionViewController else { return } + guard let destinationViewController = segue.destination as? GameViewController else { return } guard let cell = sender as? UICollectionViewCell else { return } let indexPath = sourceViewController.collectionView?.indexPath(for: cell) diff --git a/Delta/Pause Menu/Cheats/CheatValidator.swift b/Delta/Pause Menu/Cheats/CheatValidator.swift index 0c2593d..7ae51c6 100644 --- a/Delta/Pause Menu/Cheats/CheatValidator.swift +++ b/Delta/Pause Menu/Cheats/CheatValidator.swift @@ -12,7 +12,7 @@ import DeltaCore extension CheatValidator { - enum Error: ErrorProtocol + enum Error: Swift.Error { case invalidCode case invalidName diff --git a/Delta/Pause Menu/Cheats/CheatsViewController.swift b/Delta/Pause Menu/Cheats/CheatsViewController.swift index 550836c..949db04 100644 --- a/Delta/Pause Menu/Cheats/CheatsViewController.swift +++ b/Delta/Pause Menu/Cheats/CheatsViewController.swift @@ -46,9 +46,9 @@ extension CheatsViewController self.backgroundView.isHidden = false self.backgroundView.autoresizingMask = [.flexibleWidth, .flexibleHeight] self.backgroundView.textLabel.text = NSLocalizedString("No Cheats", comment: "") - self.backgroundView.textLabel.textColor = UIColor.white() + self.backgroundView.textLabel.textColor = UIColor.white self.backgroundView.detailTextLabel.text = NSLocalizedString("You can add a new cheat by pressing the + button in the top right.", comment: "") - self.backgroundView.detailTextLabel.textColor = UIColor.white() + self.backgroundView.detailTextLabel.textColor = UIColor.white self.tableView.backgroundView = self.backgroundView self.registerForPreviewing(with: self, sourceView: self.tableView) @@ -135,7 +135,7 @@ private extension CheatsViewController /// Convenience private extension CheatsViewController { - func configure(cell: UITableViewCell, forIndexPath indexPath: IndexPath) + func configure(_ cell: UITableViewCell, forIndexPath indexPath: IndexPath) { let cheat = self.fetchedResultsController.object(at: indexPath) as! Cheat cell.textLabel?.text = cheat.name @@ -173,7 +173,7 @@ extension CheatsViewController override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: RSTGenericCellIdentifier, for: indexPath) - self.configure(cell: cell, forIndexPath: indexPath) + self.configure(cell, forIndexPath: indexPath) return cell } } diff --git a/Delta/Pause Menu/Cheats/EditCheatViewController.swift b/Delta/Pause Menu/Cheats/EditCheatViewController.swift index 0a9d9f5..6374c09 100644 --- a/Delta/Pause Menu/Cheats/EditCheatViewController.swift +++ b/Delta/Pause Menu/Cheats/EditCheatViewController.swift @@ -160,7 +160,7 @@ extension EditCheatViewController guard let cheat = self.cheat else { return [] } let copyCodeAction = UIPreviewAction(title: NSLocalizedString("Copy Code", comment: ""), style: .default) { (action, viewController) in - UIPasteboard.general().string = cheat.code + UIPasteboard.general.string = cheat.code } let presentingViewController = self.presentingViewController! diff --git a/Delta/Pause Menu/PauseMenuViewController.swift b/Delta/Pause Menu/PauseMenuViewController.swift index 1b8ac1f..cf7269c 100644 --- a/Delta/Pause Menu/PauseMenuViewController.swift +++ b/Delta/Pause Menu/PauseMenuViewController.swift @@ -72,21 +72,21 @@ private extension PauseMenuViewController cell.imageView.image = pauseItem.image cell.imageView.contentMode = .center cell.imageView.layer.borderWidth = 2 - cell.imageView.layer.borderColor = UIColor.white().cgColor + cell.imageView.layer.borderColor = UIColor.white.cgColor cell.imageView.layer.cornerRadius = 10 cell.textLabel.text = pauseItem.text - cell.textLabel.textColor = UIColor.white() + cell.textLabel.textColor = UIColor.white if pauseItem.selected { - cell.imageView.tintColor = UIColor.black() - cell.imageView.backgroundColor = UIColor.white() + cell.imageView.tintColor = UIColor.black + cell.imageView.backgroundColor = UIColor.white } else { - cell.imageView.tintColor = UIColor.white() - cell.imageView.backgroundColor = UIColor.clear() + cell.imageView.tintColor = UIColor.white + cell.imageView.backgroundColor = UIColor.clear } } diff --git a/Delta/Pause Menu/PauseViewController.swift b/Delta/Pause Menu/PauseViewController.swift index fe7d023..4f6dc42 100644 --- a/Delta/Pause Menu/PauseViewController.swift +++ b/Delta/Pause Menu/PauseViewController.swift @@ -89,10 +89,10 @@ extension PauseViewController switch identifier { case "embedNavigationController": - self.pauseNavigationController = segue.destinationViewController as! UINavigationController + self.pauseNavigationController = segue.destination as! UINavigationController self.pauseNavigationController.delegate = self self.pauseNavigationController.navigationBar.tintColor = UIColor.deltaLightPurpleColor() - self.pauseNavigationController.view.backgroundColor = UIColor.clear() + self.pauseNavigationController.view.backgroundColor = UIColor.clear let pauseMenuViewController = self.pauseNavigationController.topViewController as! PauseMenuViewController pauseMenuViewController.items = self.pauseItems @@ -101,14 +101,14 @@ extension PauseViewController self.view.addSubview(self.pauseNavigationController.navigationBar) case "saveStates": - let saveStatesViewController = segue.destinationViewController as! SaveStatesViewController + let saveStatesViewController = segue.destination as! SaveStatesViewController saveStatesViewController.delegate = self.saveStatesViewControllerDelegate saveStatesViewController.game = self.emulatorCore?.game as? Game saveStatesViewController.emulatorCore = self.emulatorCore saveStatesViewController.mode = self.saveStatesViewControllerMode case "cheats": - let cheatsViewController = segue.destinationViewController as! CheatsViewController + let cheatsViewController = segue.destination as! CheatsViewController cheatsViewController.delegate = self.cheatsViewControllerDelegate cheatsViewController.game = self.emulatorCore?.game as? Game diff --git a/Delta/Pause Menu/Presentation Controller/PausePresentationController.swift b/Delta/Pause Menu/Presentation Controller/PausePresentationController.swift index 7bd4d9e..52231f1 100644 --- a/Delta/Pause Menu/Presentation Controller/PausePresentationController.swift +++ b/Delta/Pause Menu/Presentation Controller/PausePresentationController.swift @@ -37,14 +37,14 @@ class PausePresentationController: UIPresentationController override func frameOfPresentedViewInContainerView() -> CGRect { - guard let containerView = self.containerView else { return super.frameOfPresentedViewInContainerView() } + guard let containerView = self.containerView else { return super.frameOfPresentedViewInContainerView } let frame: CGRect let contentHeight = self.presentedViewController.preferredContentSize.height if contentHeight == 0 { - let statusBarHeight = UIApplication.shared().statusBarFrame.height + let statusBarHeight = UIApplication.shared.statusBarFrame.height frame = CGRect(x: 0, y: statusBarHeight, width: containerView.bounds.width, height: containerView.bounds.height - statusBarHeight) } else @@ -83,7 +83,7 @@ class PausePresentationController: UIPresentationController self.contentView.alpha = 0.0 self.vibrancyView.contentView.addSubview(self.contentView) - self.presentingViewController.transitionCoordinator()?.animate(alongsideTransition: { context in + self.presentingViewController.transitionCoordinator?.animate(alongsideTransition: { context in let blurEffect = UIBlurEffect(style: .dark) @@ -97,7 +97,7 @@ class PausePresentationController: UIPresentationController override func dismissalTransitionWillBegin() { - self.presentingViewController.transitionCoordinator()?.animate(alongsideTransition: { context in + self.presentingViewController.transitionCoordinator?.animate(alongsideTransition: { context in self.blurringView.effect = nil self.vibrancyView.effect = nil self.contentView.alpha = 0.0 @@ -120,10 +120,10 @@ class PausePresentationController: UIPresentationController self.contentView.frame = self.containerView!.bounds self.contentView.frame.origin.y = currentY - if self.presentedView()!.frame.minY == 0 + if self.presentedView!.frame.minY == 0 { // Temporarily offset top of presentedView by a small amount to prevent navigation bar from growing when rotating from landscape to portrait - self.presentedView()?.frame.origin.y = 0.5 + self.presentedView?.frame.origin.y = 0.5 } } @@ -143,7 +143,7 @@ class PausePresentationController: UIPresentationController self.contentView.removeFromSuperview() // Temporarily match the bounds of self.containerView (accounting for the status bar) - let statusBarHeight = UIApplication.shared().statusBarFrame.height + let statusBarHeight = UIApplication.shared.statusBarFrame.height self.contentView.frame = CGRect(x: 0, y: statusBarHeight, width: self.containerView!.bounds.width, height: self.containerView!.bounds.height - statusBarHeight) // Layout content view @@ -158,13 +158,13 @@ class PausePresentationController: UIPresentationController // Ensure width is correct - self.presentedView()?.bounds.size.width = self.containerView!.bounds.width - self.presentedView()?.setNeedsLayout() - self.presentedView()?.layoutIfNeeded() + self.presentedView?.bounds.size.width = self.containerView!.bounds.width + self.presentedView?.setNeedsLayout() + self.presentedView?.layoutIfNeeded() - if self.presentingViewController.transitionCoordinator() == nil + if self.presentingViewController.transitionCoordinator == nil { - self.presentedView()?.frame = self.frameOfPresentedViewInContainerView() + self.presentedView?.frame = self.frameOfPresentedViewInContainerView() } // Unhide pauseIconImageView so its height is involved with layout calculations diff --git a/Delta/Pause Menu/Save States/SaveStatesCollectionHeaderView.swift b/Delta/Pause Menu/Save States/SaveStatesCollectionHeaderView.swift index 8ab3f84..37f4ae5 100644 --- a/Delta/Pause Menu/Save States/SaveStatesCollectionHeaderView.swift +++ b/Delta/Pause Menu/Save States/SaveStatesCollectionHeaderView.swift @@ -29,7 +29,7 @@ class SaveStatesCollectionHeaderView: UICollectionReusableView private func initialize() { self.textLabel.translatesAutoresizingMaskIntoConstraints = false - self.textLabel.textColor = UIColor.white() + self.textLabel.textColor = UIColor.white var fontDescriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: UIFontTextStyleTitle3) fontDescriptor = fontDescriptor.withSymbolicTraits([.traitBold])! diff --git a/Delta/Pause Menu/Save States/SaveStatesViewController.swift b/Delta/Pause Menu/Save States/SaveStatesViewController.swift index 30d9fee..21c3c9a 100644 --- a/Delta/Pause Menu/Save States/SaveStatesViewController.swift +++ b/Delta/Pause Menu/Save States/SaveStatesViewController.swift @@ -58,7 +58,7 @@ class SaveStatesViewController: UICollectionViewController private var fetchedResultsController: NSFetchedResultsController! private let imageOperationQueue = RSTOperationQueue() - private let imageCache = Cache() + private let imageCache = Cache() private var emulatorCoreSaveState: SaveStateProtocol? private var selectedSaveState: SaveState? @@ -88,13 +88,13 @@ extension SaveStatesViewController self.backgroundView.isHidden = true self.backgroundView.autoresizingMask = [.flexibleWidth, .flexibleHeight] self.backgroundView.textLabel.text = NSLocalizedString("No Save States", comment: "") - self.backgroundView.textLabel.textColor = UIColor.white() - self.backgroundView.detailTextLabel.textColor = UIColor.white() + self.backgroundView.textLabel.textColor = UIColor.white + self.backgroundView.detailTextLabel.textColor = UIColor.white self.view.insertSubview(self.backgroundView, at: 0) let collectionViewLayout = self.collectionViewLayout as! GridCollectionViewLayout let averageHorizontalInset = (collectionViewLayout.sectionInset.left + collectionViewLayout.sectionInset.right) / 2 - let portraitScreenWidth = UIScreen.main().coordinateSpace.convert(UIScreen.main().bounds, to: UIScreen.main().fixedCoordinateSpace).width + let portraitScreenWidth = UIScreen.main.coordinateSpace.convert(UIScreen.main.bounds, to: UIScreen.main.fixedCoordinateSpace).width // Use dimensions that allow two cells to fill the screen horizontally with padding in portrait mode // We'll keep the same size for landscape orientation, which will allow more to fit @@ -185,7 +185,7 @@ private extension SaveStatesViewController { let saveState = self.fetchedResultsController.object(at: indexPath) as! SaveState - cell.imageView.backgroundColor = UIColor.white() + cell.imageView.backgroundColor = UIColor.white cell.imageView.image = UIImage(named: "DeltaPlaceholder") if !ignoreOperations @@ -215,7 +215,7 @@ private extension SaveStatesViewController let dimensions = deltaCore.emulatorConfiguration.videoBufferInfo.outputDimensions cell.maximumImageSize = CGSize(width: self.prototypeCellWidthConstraint.constant, height: (self.prototypeCellWidthConstraint.constant / dimensions.width) * dimensions.height) - cell.textLabel.textColor = UIColor.white() + cell.textLabel.textColor = UIColor.white cell.textLabel.font = UIFont.preferredFont(forTextStyle: UIFontTextStyleSubheadline) let name = saveState.name ?? self.dateFormatter.string(from: saveState.modifiedDate) @@ -509,7 +509,7 @@ private extension SaveStatesViewController // Kinda hacky, but isMovingFromParentViewController only returns yes when popping off navigation controller, and not being dismissed modally // Because of this, this is only run when the user returns to PauseMenuViewController, and not when they choose a save state to load - guard self.isMovingFromParentViewController() else { return } + guard self.isMovingFromParentViewController else { return } self.prepareEmulatorCore() } diff --git a/Delta/Pause Menu/Segues/PauseStoryboardSegue.swift b/Delta/Pause Menu/Segues/PauseStoryboardSegue.swift index ffc2bf3..f154328 100644 --- a/Delta/Pause Menu/Segues/PauseStoryboardSegue.swift +++ b/Delta/Pause Menu/Segues/PauseStoryboardSegue.swift @@ -25,14 +25,14 @@ class PauseStoryboardSegue: UIStoryboardSegue override func perform() { - self.destinationViewController.transitioningDelegate = self - self.destinationViewController.modalPresentationStyle = .custom - self.destinationViewController.modalPresentationCapturesStatusBarAppearance = true + self.destination.transitioningDelegate = self + self.destination.modalPresentationStyle = .custom + self.destination.modalPresentationCapturesStatusBarAppearance = true // We need to force layout of destinationViewController.view _before_ animateTransition(using:) // Otherwise, we'll get "Unable to simultaneously satisfy constraints" errors - self.destinationViewController.view.frame = self.sourceViewController.view.frame - self.destinationViewController.view.layoutIfNeeded() + self.destination.view.frame = self.source.view.frame + self.destination.view.layoutIfNeeded() super.perform() } @@ -69,8 +69,8 @@ extension PauseStoryboardSegue: UIViewControllerAnimatedTransitioning let presentedViewController = transitionContext.viewController(forKey: UITransitionContextToViewControllerKey)! presentedView.frame = transitionContext.finalFrame(for: presentedViewController) - presentedView.frame.origin.y = transitionContext.containerView().bounds.height - transitionContext.containerView().addSubview(presentedView) + presentedView.frame.origin.y = transitionContext.containerView.bounds.height + transitionContext.containerView.addSubview(presentedView) self.animator.addAnimations { [unowned self] in presentedView.frame = self.presentationController.frameOfPresentedViewInContainerView() diff --git a/Delta/Pause Menu/Segues/PauseTransitionCoordinator.swift b/Delta/Pause Menu/Segues/PauseTransitionCoordinator.swift index 22e29a9..57df702 100644 --- a/Delta/Pause Menu/Segues/PauseTransitionCoordinator.swift +++ b/Delta/Pause Menu/Segues/PauseTransitionCoordinator.swift @@ -32,14 +32,14 @@ class PauseTransitionCoordinator: NSObject, UIViewControllerAnimatedTransitionin let sourceViewController = transitionContext.viewController(forKey: UITransitionContextFromViewControllerKey)! destinationViewController.view.frame = transitionContext.finalFrame(for: destinationViewController) - destinationViewController.view.frame.origin.y = self.presenting ? transitionContext.containerView().bounds.height : -destinationViewController.view.bounds.height - transitionContext.containerView().addSubview(destinationViewController.view) + destinationViewController.view.frame.origin.y = self.presenting ? transitionContext.containerView.bounds.height : -destinationViewController.view.bounds.height + transitionContext.containerView.addSubview(destinationViewController.view) destinationViewController.view.layoutIfNeeded() UIView.animate(withDuration: self.transitionDuration(using: transitionContext), delay:0, options:RSTSystemTransitionAnimationCurve, animations: { - sourceViewController.view.frame.origin.y = self.presenting ? -sourceViewController.view.bounds.height : transitionContext.containerView().bounds.height + sourceViewController.view.frame.origin.y = self.presenting ? -sourceViewController.view.bounds.height : transitionContext.containerView.bounds.height destinationViewController.view.frame.origin.y = 0 self.presentationController.containerView?.setNeedsLayout() diff --git a/Delta/Settings/ControllersSettingsViewController.swift b/Delta/Settings/ControllersSettingsViewController.swift index 2fd2394..85ca6e5 100644 --- a/Delta/Settings/ControllersSettingsViewController.swift +++ b/Delta/Settings/ControllersSettingsViewController.swift @@ -19,7 +19,7 @@ private enum ControllersSettingsSection: Int private class LocalDeviceController: ExternalController { override var name: String { - return UIDevice.current().name + return UIDevice.current.name } } diff --git a/Delta/Settings/SettingsViewController.swift b/Delta/Settings/SettingsViewController.swift index 14791b8..a0eddc0 100644 --- a/Delta/Settings/SettingsViewController.swift +++ b/Delta/Settings/SettingsViewController.swift @@ -53,7 +53,7 @@ class SettingsViewController: UITableViewController { if segue.identifier == SettingsSegues.Controllers.rawValue { - let controllersSettingsViewController = segue.destinationViewController as! ControllersSettingsViewController + let controllersSettingsViewController = segue.destination as! ControllersSettingsViewController controllersSettingsViewController.playerIndex = (self.tableView.indexPathForSelectedRow as NSIndexPath?)?.row } } @@ -94,7 +94,7 @@ extension SettingsViewController { if (indexPath as NSIndexPath).row == Settings.localControllerPlayerIndex { - cell.detailTextLabel?.text = UIDevice.current().name + cell.detailTextLabel?.text = UIDevice.current.name } else if let index = ExternalControllerManager.shared.connectedControllers.index(where: { $0.playerIndex == (indexPath as NSIndexPath).row }) {